Skip to content

Commit

Permalink
remote show: do not show symbolic refs
Browse files Browse the repository at this point in the history
For symbolic refs, a sane notion of being "stale" is that the ref
they point to no longer exists.  Since this is checked already,
"remote show" does not need to show them at all.

Incidentally, this fixes the issue that "HEAD" was shown as a
stale ref by "remote show" in a freshly cloned repository.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
dscho authored and gitster committed Mar 20, 2008
1 parent a811e4f commit 740fdd2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion builtin-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ static int handle_one_branch(const char *refname,
if (!remote_find_tracking(states->remote, &refspec)) {
struct path_list_item *item;
const char *name = skip_prefix(refspec.src, "refs/heads/");
if (unsorted_path_list_has_path(&states->tracked, name) ||
/* symbolic refs pointing nowhere were handled already */
if ((flags & REF_ISSYMREF) ||
unsorted_path_list_has_path(&states->tracked,
name) ||
unsorted_path_list_has_path(&states->new,
name))
return 0;
Expand Down
10 changes: 10 additions & 0 deletions t/t5505-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,14 @@ test_expect_success 'update default (overridden, with funny whitespace)' '
'

test_expect_success '"remote show" does not show symbolic refs' '
git clone one three &&
(cd three &&
git remote show origin > output &&
! grep HEAD < output &&
! grep -i stale < output)
'

test_done

0 comments on commit 740fdd2

Please sign in to comment.