Subject: Re: [PATCH v4 4/8] fetch: fix missing from-reference when fetching HEAD:foo

From: Patrick Steinhardt <[email-masked]>
Date: Wed, 10 May 2023 14:34:57 +0200

On Tue, May 09, 2023 at 12:28:16PM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <[email-masked]> writes:
> 
> > But it is not intended when displaying the updated references and would
> > cause us to miss the left-hand side of the displayed reference update:
> >
> > ```
> > $ git fetch origin HEAD:foo
> > From https://github.com/git/git
> >  * [new ref]                          -> foo
> > ```
> > The HEAD string is clearly missing from the left-hand side of the arrow,
> > which is further stressed by the point that the following commands show
> > the left-hand side as expected:
> >
> > ```
> > $ git fetch origin HEAD
> > From https://github.com/git/git
> >  * branch                  HEAD       -> FETCH_HEAD
> 
> I do not mind being explicit and showing HEAD in this case for the
> sake of consistency.
> 
> But speaking for the past developers, it was deliberate to omit what
> is common from the output to make it more terse, IIRC, and I think
> it is unfair to call it a "BUG".
> 
> Back when we wrote git-fetch-script, the output was a lot more
> verbose, and through efforts like 165f3902 (git-fetch: more terse
> fetch output, 2007-11-03) and numerous others over time, we got to
> the current output.

That's fair. It's still not quite clear whether this behaviour is in
fact intentional though. Quoting 165f3902 (git-fetch: more terse
fetch output, 2007-11-03), the weird corner case is not documented:

    This makes the fetch output much more terse and prettier on a 80 column
    display, based on a consensus reached on the mailing list.  Here's an
    example output:

    Receiving objects: 100% (5439/5439), 1.60 MiB | 636 KiB/s, done.
    Resolving deltas: 100% (4604/4604), done.
    From git://git.kernel.org/pub/scm/git/git
     ! [rejected]        html -> origin/html  (non fast forward)
       136e631..f45e867  maint -> origin/maint  (fast forward)
       9850e2e..44dd7e0  man -> origin/man  (fast forward)
       3e4bb08..e3d6d56  master -> origin/master  (fast forward)
       fa3665c..536f64a  next -> origin/next  (fast forward)
     + 4f6d9d6...768326f pu -> origin/pu  (forced update)
     * [new branch]      todo -> origin/todo

I've reformulated the commit message to talk about an inconsistency
instead of a bug.

Patrick