Code

remote show: do not show symbolic refs
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Wed, 19 Mar 2008 00:27:42 +0000 (00:27 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Mar 2008 00:33:30 +0000 (17:33 -0700)
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>
builtin-remote.c
t/t5505-remote.sh

index 24e692953b25164e7418efc24b5cd685e61bd1d0..9c15173032f8566539a10b93074e15d493dd17d7 100644 (file)
@@ -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;
index ecfc999aaae728e3f57beaab60490abc53a3fb23..004a8dc5ed28f57de76935c4f02803fe6496d4d6 100755 (executable)
@@ -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