Skip to content

Commit

Permalink
builtin-remote: fix two inconsistencies in the output of "show <remote>"
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jay Soffian authored and Junio C Hamano committed Feb 27, 2009
1 parent cca7c97 commit 3bd9256
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions builtin-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,8 @@ static int handle_one_branch(const char *refname,
const char *name = abbrev_branch(refspec.src);
/* symbolic refs pointing nowhere were handled already */
if ((flags & REF_ISSYMREF) ||
unsorted_string_list_has_string(&states->tracked,
name) ||
unsorted_string_list_has_string(&states->new,
name))
string_list_has_string(&states->tracked, name) ||
string_list_has_string(&states->new, name))
return 0;
item = string_list_append(name, &states->stale);
item->util = xstrdup(refname);
Expand Down Expand Up @@ -258,6 +256,8 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat
}
free_refs(fetch_map);

sort_string_list(&states->new);
sort_string_list(&states->tracked);
for_each_ref(handle_one_branch, states);
sort_string_list(&states->stale);

Expand Down Expand Up @@ -638,6 +638,9 @@ static int append_ref_to_tracked_list(const char *refname,
struct ref_states *states = cb_data;
struct refspec refspec;

if (flags & REF_ISSYMREF)
return 0;

memset(&refspec, 0, sizeof(refspec));
refspec.dst = (char *)refname;
if (!remote_find_tracking(states->remote, &refspec))
Expand Down Expand Up @@ -666,8 +669,10 @@ static int get_remote_ref_states(const char *name,
transport_disconnect(transport);

get_ref_states(remote_refs, states);
} else
} else {
for_each_ref(append_ref_to_tracked_list, states);
sort_string_list(&states->tracked);
}

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion t/t5505-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ cat > test/expect << EOF
New remote branch (next fetch will store in remotes/origin)
master
Tracked remote branches
side
master
side
Local branches pushed with 'git push'
master:upstream
+refs/tags/lastbackup
Expand Down

0 comments on commit 3bd9256

Please sign in to comment.