@matheusbsbs / matheus-bagliano / commits / 3bd925636c
Fork 0

builtin-remote: fix two inconsistencies in the output of "show <remote>"

Remote and stale branches are emitted in alphabetical order, but new and tracked branches are not. So sort the latter to be consistent with the former. This also lets us use more efficient string_list_has_string() instead of unsorted_string_list_has_string(). "show <remote>" prunes symrefs, but "show <remote> -n" does not. Fix the latter to match the former. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jay Soffian committed Feb 25, 2009 at 03:32 UTC 3bd925636cd11400d1840b39d0d18b640f32bdd2
2 files changed +11 -6
builtin-remote.c
+10 -5
@@ -226,10 +226,8 @@ static int handle_one_branch(const char *refname,
226 const char *name = abbrev_branch(refspec.src);
227 /* symbolic refs pointing nowhere were handled already */
228 if ((flags & REF_ISSYMREF) ||
229 - unsorted_string_list_has_string(&states->tracked,
230 - name) ||
231 - unsorted_string_list_has_string(&states->new,
232 - name))
229 + string_list_has_string(&states->tracked, name) ||
230 + string_list_has_string(&states->new, name))
231 return 0;
232 item = string_list_append(name, &states->stale);
233 item->util = xstrdup(refname);
@@ -258,6 +256,8 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat
256 }
257 free_refs(fetch_map);
258
259 + sort_string_list(&states->new);
260 + sort_string_list(&states->tracked);
261 for_each_ref(handle_one_branch, states);
262 sort_string_list(&states->stale);
263
@@ -638,6 +638,9 @@ static int append_ref_to_tracked_list(const char *refname,
638 struct ref_states *states = cb_data;
639 struct refspec refspec;
640
641 + if (flags & REF_ISSYMREF)
642 + return 0;
643 +
644 memset(&refspec, 0, sizeof(refspec));
645 refspec.dst = (char *)refname;
646 if (!remote_find_tracking(states->remote, &refspec))
@@ -666,8 +669,10 @@ static int get_remote_ref_states(const char *name,
669 transport_disconnect(transport);
670
671 get_ref_states(remote_refs, states);
669 - } else
672 + } else {
673 for_each_ref(append_ref_to_tracked_list, states);
674 + sort_string_list(&states->tracked);
675 + }
676
677 return 0;
678 }
t/t5505-remote.sh
+1 -1
@@ -141,8 +141,8 @@ cat > test/expect << EOF
141 New remote branch (next fetch will store in remotes/origin)
142 master
143 Tracked remote branches
144 - side
144 master
145 + side
146 Local branches pushed with 'git push'
147 master:upstream
148 +refs/tags/lastbackup