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

[PATCH] fetch: show remote name instead of URL if available

From
Dan McGee <dpmcgee@gmail.com>
Date
Apr 26, 2011, 15:13 UTC
Message-ID
<1303830807-21966-1-git-send-email-dpmcgee@gmail.com>

We often have a name such as 'origin' available; use it if so rather than showing the raw URL.

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
---
The old output:
    $ git fetch -v
    From git://git.kernel.org/pub/scm/git/git
     = [up to date]      html       -> origin/html
    ...
Versus the new output:
    $ ./git fetch -v
    From origin
     = [up to date]      html       -> origin/html
    ...
Alternatively, we could do something like
    From origin (git://git.kernel.org/pub/scm/git/git)
but no other command seems to do such a thing. Note that a fetch with a direct
URL rather than a name will still show the URL as before.

Another RFC in this is the behavior of `git ls-remote`- it also shows a URL when we may have a nice name available, so I can resubmit with that modified as well if people agree with the change. The difference is porcelain vs plumbing.

-Dan
 builtin/fetch.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index f9c41da..01bda5a 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -436,8 +436,12 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 				 REFCOL_WIDTH, *what ? what : "HEAD");
 		if (*note) {
 			if (verbosity >= 0 && !shown_url) {
-				fprintf(stderr, _("From %.*s\n"),
-						url_len, url);
+				if (remote_name)
+					fprintf(stderr, _("From %s\n"),
+							remote_name);
+				else
+					fprintf(stderr, _("From %.*s\n"),
+							url_len, url);
 				shown_url = 1;
 			}
 			if (verbosity >= 0)
-- 
1.7.5
Next: Junio C Hamano
Message 1 of 3 in “fetch: show remote name instead of URL if available”
  1. fetch: show remote name instead of URL if availableDan McGee, Apr 26, 2011
  2. Junio C HamanoApr 26, 2011
  3. Drew NorthupApr 26, 2011

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.