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.