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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 5/20/2025 9:30 AM, Junio C Hamano wrote:
> Jacob Keller <jacob.e.keller@xxxxxxxxx> 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. :(

>> +	... 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.

> 
>> +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.

>> +
>> +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.





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux