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

Re: [PATCH] log: diagnose -L used with pathspec as an error

From
Jeff King <peff@peff.net>
Date
Nov 4, 2020, 21:03 UTC
Message-ID
<20201104210327.GG3629238@coredump.intra.peff.net>
In-Reply-To
<xmqqy2jglv29.fsf_-_@gitster.c.googlers.com>
On Wed, Nov 04, 2020 at 12:35:10PM -0800, Junio C Hamano wrote:
Show 5 quoted lines
> The new tests say they may fail with "-L and --follow being
> incompatible" instead of "-L and pathspec being imcompatible".
> Currently the expected failure can come only from the latter, but
> this is to futureproof them, in case we decide to add code to
> explicititly die on -L and --follow used together.
This explanation makes sense (though s/imcompat/incompat/).
Show 9 quoted lines
> +test_expect_success 'basic command line parsing' '
> +	# This may fail due to "no such path a.c in commit", or
> +	# "-L is incompatible with pathspec", depending on the
> +	# order the error is checked.  Either is acceptable.
> +	test_must_fail git log -L1,1:a.c -- a.c &&
> +
> +	# This must fail due to "-L is incompatible with pathspec".
> +	test_must_fail git log -L1,1:b.c -- b.c 2>error &&
> +	test_i18ngrep "cannot be used with pathspec" error &&
The renaming makes sense...
> +
> +	# Note that incompatibility between -L/--follow is not
> +	# explicitly checked to avoid redundant code and the comments
> +	# on the following tests are merely for future-proofing.
...as does this comment to explain the rest of the tests.
Show 11 quoted lines
> +	# These must fail due to "follow requires one pathspec", or
> +	# "-L is incompatible with --follow", depending on the
> +	# order the error is checked.  Either is acceptable.
> +	test_must_fail git log -L1,1:b.c --follow &&
> +	test_must_fail git log --follow -L1,1:b.c &&
> +
> +	# This may fail due to "-L is incompatible with pathspec", or
> +	# "-L is incompatible with --follow", depending on the
> +	# order the error is checked.  Either is acceptable.
> +	test_must_fail git log --follow -L1,1:b.c -- b.c
> +'

Though "depending on the order" is a bit of a fiction, because those checks do not exist at all. I'm OK with it because the earlier comment explains what is going. I guess:

  # This may fail due to "-L is incompatible with pathspec", or
  # "-L is incompatible with --follow". We don't have the latter as of
  # the writing of this test, but either would be acceptable if we added
  # it.

would be an alternative. I doubt it's worth spending too much time polishing.

-Peff
Previous: Junio C HamanoNext: Derrick Stolee
Message 17 of 23 in “Segfault in git when using git logs”
  1. Sathyajith BhatNov 2, 2020
  2. Jeff KingNov 2, 2020
  3. Junio C HamanoNov 2, 2020
  4. SZEDER GáborNov 3, 2020
  5. Christian CouderNov 3, 2020
  6. Elijah NewrenNov 3, 2020
  7. Jeff KingNov 3, 2020
  8. Junio C HamanoNov 3, 2020
  9. Jeff KingNov 3, 2020
  10. Junio C HamanoNov 3, 2020
  11. Jeff KingNov 4, 2020
  12. Junio C HamanoNov 4, 2020
  13. Re*: Segfault in git when using git logsJunio C Hamano, Nov 4, 2020
  14. Jeff KingNov 4, 2020
  15. Junio C HamanoNov 4, 2020
  16. log: diagnose -L used with pathspec as an errorJunio C Hamano, Nov 4, 2020
  17. Jeff KingNov 4, 2020
  18. Derrick StoleeNov 3, 2020
  19. Sathyajith BhatNov 3, 2020
  20. Jeff KingNov 3, 2020
  21. Derrick StoleeNov 3, 2020
  22. Derrick StoleeNov 3, 2020
  23. Sathyajith BhatNov 4, 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.