git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] remote show: do not show symbolic refs

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 19, 2008, 00:27 UTC
Message-ID
<alpine.DEB.1.00.0803182119320.2323@eeepc-johanness>
In-Reply-To
<7v7ig096ot.fsf@gitster.siamese.dyndns.org>

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>
---
	On Mon, 17 Mar 2008, Junio C Hamano wrote:
	> "git remote" showing remotes/origin/HEAD as a candidate for 
	> pruning, and pruning it results in removal of what is pointed at 
	> by it.
	>
	> Pointers?  This may not be a regression but bug-to-bug 
	> compatibility with the older implementation, but this should 
	> better be fixed.
	How about this?
 builtin-remote.c  |    5 ++++-
 t/t5505-remote.sh |   10 ++++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/builtin-remote.c b/builtin-remote.c
index 8e7fa6a..67139ec 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -210,7 +210,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;
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index ecfc999..004a8dc 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -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
-- 
1.5.5.rc0.173.g90d70
Previous: Sam Vilain
Message 5 of 5 in “Unresolved issues”
  1. Junio C HamanoMar 18, 2008
  2. Jeff KingMar 18, 2008
  3. Linus TorvaldsMar 18, 2008
  4. Sam VilainMar 19, 2008
  5. remote show: do not show symbolic refsJohannes Schindelin, Mar 19, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.