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

3 messages from 2011-04-26 to 2011-04-26. Participants: Dan McGee, Junio C Hamano, Drew Northup.
Thread: https://gitlist.dev/t/27190

## Dan McGee, 2011-04-26 15:13

Subject: [PATCH] fetch: show remote name instead of URL if available
Message-ID: <1303830807-21966-1-git-send-email-dpmcgee@gmail.com>
URL: https://gitlist.dev/e/1303830807-21966-1-git-send-email-dpmcgee%40gmail.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

```

## Junio C Hamano, 2011-04-26 17:33

Subject: Re: [PATCH] fetch: show remote name instead of URL if available
Message-ID: <7v1v0ogbnn.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v1v0ogbnn.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1303830807-21966-1-git-send-email-dpmcgee@gmail.com>

```
Dan McGee <dpmcgee@gmail.com> writes:

>     $ git fetch -v
>     From git://git.kernel.org/pub/scm/git/git
>      = [up to date]      html       -> origin/html
>     ...

I see this full URL output as a nice reminder of what "origin" refers to,
especially when you said "git fetch -v origin".  This is especially useful
when you are fetching from different locations that house repositories of
the same project (e.g. among my multiple git.git working trees on my
notebook, some of them fetch from my private, primaty development machine
and others from public k.org).

Changing this output ...

> Versus the new output:
>
>     $ ./git fetch -v
>     From origin

... this way feels like a regression to me.

> Alternatively, we could do something like
>     From origin (git://git.kernel.org/pub/scm/git/git)

That is much less problematic.

But let's step back a bit.  What problem are you trying to solve?

Are you trying to give a reminder that you are interacting with 'origin'
when you said "git fetch -v" without saying where you are fetching from?
I think that is a good thing to aim for (the same reasoning behind the
comment of mine above).  If so, the ideal change from my gut feeling is to
add an extra " (origin)" at the end, like so:

	From git://git.kernel.org/pub/scm/git/git (origin)

when and only when the fetch is done without mentioning any remote
nickname; iow, "git fetch -v origin" or "git fetch -v git://.../git" won't
get the extra " (origin)" at the end.

```

## Drew Northup, 2011-04-26 17:36

Subject: Re: [PATCH] fetch: show remote name instead of URL if available
Message-ID: <1303839386.18603.19.camel@drew-northup.unet.maine.edu>
URL: https://gitlist.dev/e/1303839386.18603.19.camel%40drew-northup.unet.maine.edu
In-Reply-To: <7v1v0ogbnn.fsf@alter.siamese.dyndns.org>

```

On Tue, 2011-04-26 at 10:33 -0700, Junio C Hamano wrote:
> Dan McGee <dpmcgee@gmail.com> writes:
> 
> >     $ git fetch -v
> >     From git://git.kernel.org/pub/scm/git/git
> >      = [up to date]      html       -> origin/html
> >     ...
> 
> I see this full URL output as a nice reminder of what "origin" refers to,
> especially when you said "git fetch -v origin".  This is especially useful
> when you are fetching from different locations that house repositories of
> the same project (e.g. among my multiple git.git working trees on my
> notebook, some of them fetch from my private, primaty development machine
> and others from public k.org).
> 
> Changing this output ...
> 
> > Versus the new output:
> >
> >     $ ./git fetch -v
> >     From origin
> 
> ... this way feels like a regression to me.
> 
> > Alternatively, we could do something like
> >     From origin (git://git.kernel.org/pub/scm/git/git)
> 
> That is much less problematic.
> 
> But let's step back a bit.  What problem are you trying to solve?
> 
> Are you trying to give a reminder that you are interacting with 'origin'
> when you said "git fetch -v" without saying where you are fetching from?
> I think that is a good thing to aim for (the same reasoning behind the
> comment of mine above).  If so, the ideal change from my gut feeling is to
> add an extra " (origin)" at the end, like so:
> 
> 	From git://git.kernel.org/pub/scm/git/git (origin)
> 
> when and only when the fetch is done without mentioning any remote
> nickname; iow, "git fetch -v origin" or "git fetch -v git://.../git" won't
> get the extra " (origin)" at the end.

I was about to compose mail to the same effect, so I'll just agree
instead.

-- 
-Drew Northup
________________________________________________
"As opposed to vegetable or mineral error?"
-John Pescatore, SANS NewsBites Vol. 12 Num. 59

```
