зеркало из https://github.com/microsoft/git.git
Merge branch 'rs/use-skip-prefix-more'
Code cleanup. * rs/use-skip-prefix-more: name-rev: use skip_prefix() instead of starts_with() push: use skip_prefix() instead of starts_with() shell: use skip_prefix() instead of starts_with() fmt-merge-msg: use skip_prefix() instead of starts_with() fetch: use skip_prefix() instead of starts_with()
This commit is contained in:
Коммит
391fb22ac7
|
@ -957,18 +957,12 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
|
|||
kind = "";
|
||||
what = "";
|
||||
}
|
||||
else if (starts_with(rm->name, "refs/heads/")) {
|
||||
else if (skip_prefix(rm->name, "refs/heads/", &what))
|
||||
kind = "branch";
|
||||
what = rm->name + 11;
|
||||
}
|
||||
else if (starts_with(rm->name, "refs/tags/")) {
|
||||
else if (skip_prefix(rm->name, "refs/tags/", &what))
|
||||
kind = "tag";
|
||||
what = rm->name + 10;
|
||||
}
|
||||
else if (starts_with(rm->name, "refs/remotes/")) {
|
||||
else if (skip_prefix(rm->name, "refs/remotes/", &what))
|
||||
kind = "remote-tracking branch";
|
||||
what = rm->name + 13;
|
||||
}
|
||||
else {
|
||||
kind = "";
|
||||
what = rm->name;
|
||||
|
|
|
@ -106,7 +106,7 @@ static int handle_line(char *line, struct merge_parents *merge_parents)
|
|||
int i, len = strlen(line);
|
||||
struct origin_data *origin_data;
|
||||
char *src;
|
||||
const char *origin;
|
||||
const char *origin, *tag_name;
|
||||
struct src_data *src_data;
|
||||
struct string_list_item *item;
|
||||
int pulling_head = 0;
|
||||
|
@ -162,14 +162,13 @@ static int handle_line(char *line, struct merge_parents *merge_parents)
|
|||
if (pulling_head) {
|
||||
origin = src;
|
||||
src_data->head_status |= 1;
|
||||
} else if (starts_with(line, "branch ")) {
|
||||
} else if (skip_prefix(line, "branch ", &origin)) {
|
||||
origin_data->is_local_branch = 1;
|
||||
origin = line + 7;
|
||||
string_list_append(&src_data->branch, origin);
|
||||
src_data->head_status |= 2;
|
||||
} else if (starts_with(line, "tag ")) {
|
||||
} else if (skip_prefix(line, "tag ", &tag_name)) {
|
||||
origin = line;
|
||||
string_list_append(&src_data->tag, origin + 4);
|
||||
string_list_append(&src_data->tag, tag_name);
|
||||
src_data->head_status |= 2;
|
||||
} else if (skip_prefix(line, "remote-tracking branch ", &origin)) {
|
||||
string_list_append(&src_data->r_branch, origin);
|
||||
|
|
|
@ -161,10 +161,10 @@ static const char *name_ref_abbrev(const char *refname, int shorten_unambiguous)
|
|||
{
|
||||
if (shorten_unambiguous)
|
||||
refname = shorten_unambiguous_ref(refname, 0);
|
||||
else if (starts_with(refname, "refs/heads/"))
|
||||
refname = refname + 11;
|
||||
else if (starts_with(refname, "refs/"))
|
||||
refname = refname + 5;
|
||||
else if (skip_prefix(refname, "refs/heads/", &refname))
|
||||
; /* refname already advanced */
|
||||
else
|
||||
skip_prefix(refname, "refs/", &refname);
|
||||
return refname;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ static struct string_list push_options_config = STRING_LIST_INIT_DUP;
|
|||
static const char *map_refspec(const char *ref,
|
||||
struct remote *remote, struct ref *local_refs)
|
||||
{
|
||||
const char *branch_name;
|
||||
struct ref *matched = NULL;
|
||||
|
||||
/* Does "ref" uniquely name our ref? */
|
||||
|
@ -84,8 +85,8 @@ static const char *map_refspec(const char *ref,
|
|||
}
|
||||
|
||||
if (push_default == PUSH_DEFAULT_UPSTREAM &&
|
||||
starts_with(matched->name, "refs/heads/")) {
|
||||
struct branch *branch = branch_get(matched->name + 11);
|
||||
skip_prefix(matched->name, "refs/heads/", &branch_name)) {
|
||||
struct branch *branch = branch_get(branch_name);
|
||||
if (branch->merge_nr == 1 && branch->merge[0]->src) {
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
strbuf_addf(&buf, "%s:%s",
|
||||
|
|
4
shell.c
4
shell.c
|
@ -16,10 +16,10 @@ static int do_generic_cmd(const char *me, char *arg)
|
|||
setup_path();
|
||||
if (!arg || !(arg = sq_dequote(arg)) || *arg == '-')
|
||||
die("bad argument");
|
||||
if (!starts_with(me, "git-"))
|
||||
if (!skip_prefix(me, "git-", &me))
|
||||
die("bad command");
|
||||
|
||||
my_argv[0] = me + 4;
|
||||
my_argv[0] = me;
|
||||
my_argv[1] = arg;
|
||||
my_argv[2] = NULL;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче