From: Junio C Hamano Date: Sat, 28 Mar 2009 07:42:22 +0000 (-0700) Subject: Merge branch 'js/remote-improvements' X-Git-Tag: v1.6.3-rc0~73 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/48bcfbd1342f69a523c4214804682458e1121bd9?ds=inline;hp=-c Merge branch 'js/remote-improvements' * js/remote-improvements: remote: improve sorting of "configure for git push" list --- 48bcfbd1342f69a523c4214804682458e1121bd9 diff --combined builtin-remote.c index 993acd6a09,9fdbb6c103..9ef846f6a4 --- a/builtin-remote.c +++ b/builtin-remote.c @@@ -358,9 -358,14 +358,9 @@@ static int get_push_ref_states_noquery( } for (i = 0; i < remote->push_refspec_nr; i++) { struct refspec *spec = remote->push + i; - char buf[PATH_MAX]; if (spec->matching) item = string_list_append("(matching)", &states->push); - else if (spec->pattern) { - snprintf(buf, (sizeof(buf)), "%s*", spec->src); - item = string_list_append(buf, &states->push); - snprintf(buf, (sizeof(buf)), "%s*", spec->dst); - } else if (strlen(spec->src)) + else if (strlen(spec->src)) item = string_list_append(spec->src, &states->push); else item = string_list_append("(delete)", &states->push); @@@ -368,7 -373,10 +368,7 @@@ info = item->util = xcalloc(sizeof(struct push_info), 1); info->forced = spec->force; info->status = PUSH_STATUS_NOTQUERIED; - if (spec->pattern) - info->dest = xstrdup(buf); - else - info->dest = xstrdup(spec->dst ? spec->dst : item->string); + info->dest = xstrdup(spec->dst ? spec->dst : item->string); } return 0; } @@@ -381,7 -389,7 +381,7 @@@ static int get_head_names(const struct refspec.force = 0; refspec.pattern = 1; - refspec.src = refspec.dst = "refs/heads/"; + refspec.src = refspec.dst = "refs/heads/*"; states->heads.strdup_strings = 1; get_fetch_map(remote_refs, &refspec, &fetch_map_tail, 0); matches = guess_remote_head(find_ref_by_name(remote_refs, "HEAD"), @@@ -608,8 -616,9 +608,8 @@@ static int mv(int argc, const char **ar struct string_list_item *item = remote_branches.items + i; int flag = 0; unsigned char sha1[20]; - const char *symref; - symref = resolve_ref(item->string, sha1, 1, &flag); + resolve_ref(item->string, sha1, 1, &flag); if (!(flag & REF_ISSYMREF)) continue; if (delete_ref(item->string, NULL, REF_NODEREF)) @@@ -922,6 -931,20 +922,20 @@@ int add_push_to_show_info(struct string return 0; } + /* + * Sorting comparison for a string list that has push_info + * structs in its util field + */ + static int cmp_string_with_push(const void *va, const void *vb) + { + const struct string_list_item *a = va; + const struct string_list_item *b = vb; + const struct push_info *a_push = a->util; + const struct push_info *b_push = b->util; + int cmp = strcmp(a->string, b->string); + return cmp ? cmp : strcmp(a_push->dest, b_push->dest); + } + int show_push_info_item(struct string_list_item *item, void *cb_data) { struct show_info *show_info = cb_data; @@@ -1032,7 -1055,8 +1046,8 @@@ static int show(int argc, const char ** info.width = info.width2 = 0; for_each_string_list(add_push_to_show_info, &states.push, &info); - sort_string_list(info.list); + qsort(info.list->items, info.list->nr, + sizeof(*info.list->items), cmp_string_with_push); if (info.list->nr) printf(" Local ref%s configured for 'git push'%s:\n", info.list->nr > 1 ? "s" : "",