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

[PATCH] remote.c: use shorten_unambiguous_ref

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Apr 9, 2009, 15:33 UTC
Message-ID
<1239291182-12860-1-git-send-email-git@drmicha.warpmail.net>

Use the new shorten_unambiguous_ref() for simplifying the output of upstream branch names. This affects status and checkout.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
I intentionally didn't combine the line with the previous one (see
context) to make things a bit clearer.

I haven't seen more obvious place for using shorten_unambiguous_ref(). prettify_ref() is a natural candidate but is mostly used for prettyfying refs on the remote side. git branch is covered by Jeff's patch already.

 remote.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/remote.c b/remote.c
index a06761a..10af722 100644
--- a/remote.c
+++ b/remote.c
@@ -1461,11 +1461,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
 		return 0;
 
 	base = branch->merge[0]->dst;
-	if (!prefixcmp(base, "refs/remotes/")) {
-		base += strlen("refs/remotes/");
-	} else if (!prefixcmp(base, "refs/heads/")) {
-		base += strlen("refs/heads/");
-	}
+	base = shorten_unambiguous_ref(base);
 	if (!num_theirs)
 		strbuf_addf(sb, "Your branch is ahead of '%s' "
 			    "by %d commit%s.\n",
-- 
1.6.2.2.646.gb214
Next: Jeff King
Message 1 of 7 in “remote.c: use shorten_unambiguous_ref”
  1. remote.c: use shorten_unambiguous_refMichael J Gruber, Apr 9, 2009
  2. Jeff KingApr 10, 2009
  3. Michael J GruberApr 14, 2009
  4. Jeff KingApr 15, 2009
  5. Junio C HamanoApr 14, 2009
  6. Bert WesargApr 14, 2009
  7. Jeff KingApr 15, 2009

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.