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

Re: Bogus error from git log --full-diff

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 19, 2020, 17:10 UTC
Message-ID
<xmqqtuz7hthj.fsf@gitster.c.googlers.com>
In-Reply-To
<87h7v7xf1n.fsf@igel.home>
Andreas Schwab <schwab@linux-m68k.org> writes:
> If you have log.follow=true, then git log --full-diff doesn't work any
> more, giving a bogus error:

Does "any more" mean it used to work with older version of Git, or it used to work before log.follow is thrown into the configuration file?

> $ ./git -c log.follow=true log --full-diff .
> fatal: --follow requires exactly one pathspec
I see one and half possible bogosities in here.
 * "--follow" is about following a single path, so even without
   "--full-diff", i.e. "git log --follow .", should not proceed but
   notice it as an error.  The pathspec should name a single path,
   like "helloworld.py" (and no, git does not track directories, so
   "."  is not a single path.  The pathspec "." matches everything
   under that directory).
 * "--full-diff" wants to make a full comparison between two trees
   (in the case of "git log", the child and its parent(s)), but
   "--follow" wants to make a comparison between just two blobs
   (i.e. the path that it is following in the child, and the
   "corresponding" blob in the parent commit(s)), so they are
   inherently incompatible.

Since neither is flagged as an error, the "--follow" logic is upset when "--full-diff" widens the input of the "diff" run internally (the error message comes from the fact that full-diff cleared the pathspec used to generate this diff that the "--follow" logic uses to find the corresponding path it is following---it sees zero when it wants to have one).

I said these are one-and-half, because a reasonable expectation by the end user could be that the configured log.follow is automatically turned off when any incompatible option is given from the command line, i.e.

    git -c log.follow=yes log --full-diff .
should be equivalent to
    git log --full-diff .
and not
    git log --full-diff --follow .
And with that, we should not see the bogus * 1.5 error message.

So, I see 3 potential things that can be improved. Tightened error checking for "--follow" itself, tightened error checking for mutual exclusivity, and turning configured log.follow off automatically.

Thanks.
Previous: Junio C Hamano
Message 4 of 4 in “Bogus error from git log --full-diff”
  1. Andreas SchwabJun 19, 2020
  2. Konstantin TokarevJun 19, 2020
  3. Junio C HamanoJun 19, 2020
  4. Junio C HamanoJun 19, 2020

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.