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

Re: [PATCH v3 4/4] diff --no-index: support limiting by pathspec

From
Jacob Keller <jacob.e.keller@intel.com>
Date
May 20, 2025, 22:45 UTC
Message-ID
<5343efa2-99b2-4532-b52d-0e120678470c@intel.com>
In-Reply-To
<xmqqy0uri6st.fsf@gitster.g>
On 5/20/2025 9:30 AM, Junio C Hamano wrote:
Show 8 quoted lines
> Jacob Keller <jacob.e.keller@intel.com> writes:
>> -`git diff [<options>] --no-index [--] <path> <path>`::
>> +`git diff [<options>] --no-index [--] <path> <path> [<pathspec>...]`::
> 
> This is a bit unfortunate.  The disambiguating "--" should ideally
> be between the "things to be compared" and the pathspec, as the
> former corresponds to <rev> in the normal "git diff" invocation.
> 

True, but it looks like we already had it before paths. I am not sure if we can easily change that now. :(

Show 7 quoted lines
>> +	... If both
>> +	paths point to directories, additional pathspecs may be
>> +	provided. These will limit the files included in the
>> +	difference. All such pathspecs must be relative as they
>> +	apply to both sides of the diff.
> 
> "as they" -> "and they"?

I think I meant "because they", but for documentation I think and they makes more sense. I can clarify this a bit better in the next version.

Show 18 quoted lines
> 
>> +test_expect_success 'diff --no-index with pathspec' '
>> +	test_expect_code 1 git diff --no-index a b 1 >actual &&
>> +	cat >expect <<-EOF &&
>> +	diff --git a/a/1 b/a/1
>> +	deleted file mode 100644
>> +	index d00491f..0000000
>> +	--- a/a/1
>> +	+++ /dev/null
>> +	@@ -1 +0,0 @@
>> +	-1
>> +	EOF
>> +	test_cmp expect actual
>> +'
> 
> If you use --name-only or --name-status would the test become
> simpler?
> 
That is a good idea.
Show 26 quoted lines
>> +
>> +test_expect_success 'diff --no-index with pathspec no matches' '
>> +	test_expect_code 0 git diff --no-index a b missing
>> +'
> 
> OK.
> 
>> +test_expect_success 'diff --no-index with negative pathspec' '
>> +	test_expect_code 1 git diff --no-index a b ":!2" >actual &&
>> +	cat >expect <<-EOF &&
>> +	diff --git a/a/1 b/a/1
>> +	deleted file mode 100644
>> +	index d00491f..0000000
>> +	--- a/a/1
>> +	+++ /dev/null
>> +	@@ -1 +0,0 @@
>> +	-1
>> +	EOF
>> +	test_cmp expect actual
>> +'
> 
> OK.
> 
> All other tests also look sensible.
> 
> Thanks.
Previous: Junio C HamanoNext: Jacob Keller
Message 14 of 15 in “diff: add pathspec support to --no-index”
  1. 0/4 diff: add pathspec support to --no-indexJacob Keller, May 20, 2025
  2. 1/4 prefix_path: support prefixes not ending in trailing slashJacob Keller, May 20, 2025
  3. Junio C HamanoMay 20, 2025
  4. Jacob KellerMay 20, 2025
  5. 2/4 pathspec: expose match_pathspec_with_flagsJacob Keller, May 20, 2025
  6. Junio C HamanoMay 20, 2025
  7. Jacob KellerMay 20, 2025
  8. 3/4 pathspec: add flag to indicate operation without repositoryJacob Keller, May 20, 2025
  9. Junio C HamanoMay 20, 2025
  10. Jacob KellerMay 20, 2025
  11. Jacob KellerMay 21, 2025
  12. 4/4 diff --no-index: support limiting by pathspecJacob Keller, May 20, 2025
  13. Junio C HamanoMay 20, 2025
  14. Jacob KellerMay 20, 2025
  15. Jacob KellerMay 20, 2025

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.