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

Re: [PATCH] diff: add test showing regression to --relative

From
Jacob Keller <jacob.keller@gmail.com>
Date
Dec 7, 2017, 01:21 UTC
Message-ID
<CA+P7+xr8KobkY56-4qE4ZdVgC388L6=NKQc=3kTZvWz8XOD3ag@mail.gmail.com>
In-Reply-To
<20171207010421.GC1975@sigill.intra.peff.net>
On Wed, Dec 6, 2017 at 5:04 PM, Jeff King <peff@peff.net> wrote:
Show 14 quoted lines
> On Wed, Dec 06, 2017 at 04:35:17PM -0800, Jacob Keller wrote:
>
>> Subject: [PATCH] diff: add test showing regression to --relative
>
> Since we'd hopefully not ever merge that regression, I think this patch
> ought to stand on its own. In which case it probably wants to say
> something like:
>
>   diff: test --relative without a prefix
>
>   We already test "diff --relative=subdir", but not that
>   "--relative" by itself should use the current directory as
>   its prefix.
>

Yea, I wasn't sure what the actual status of the changes were though, so I thought I'd send the actual fix I did. It's definitely up to Christian in determining what he thinks the best path forward is.

Show 25 quoted lines
>> diff --git a/t/t4045-diff-relative.sh b/t/t4045-diff-relative.sh
>> index 3950f5034d31..41e4f59b2ffb 100755
>> --- a/t/t4045-diff-relative.sh
>> +++ b/t/t4045-diff-relative.sh
>> @@ -70,4 +70,9 @@ for type in diff numstat stat raw; do
>>       check_$type dir/file2 --relative=sub
>>  done
>>
>> +cd subdir
>> +for type in diff numstat stat raw; do
>> +     check_$type file2 --relative
>> +done
>
> We should avoid moving the cwd of the whole test script in
> case we add tests later. Normally we'd do the cd inside a
> subshell, but that's complicated by the wrapper (we wouldn't
> want to increment the test counter just inside the subshell,
> for instance).
>
> Adding "cd .." is the smallest thing we could do to fix
> that. But I think the more robust solution is to actually
> teach the check_* helper about doing the "cd" inside the
> test_expect block. Or just pushing the helper down into the
> test block and living with repeating the
> "test_expect_success" parts for each call.

Yea, I tried cd inside the subshell and it didn't work, so I did this as the quicker solution.

I think the best method would be to update the check_* helper functions to take a dir parameter, and use that to do git -C "dir" when calling the diff commands.

Thanks, Jake

>
> -Peff
Previous: Jeff KingNext: Junio C Hamano
Message 3 of 15 in “diff: add test showing regression to --relative”
  1. diff: add test showing regression to --relativeJacob Keller, Dec 7, 2017
  2. Jeff KingDec 7, 2017
  3. Jacob KellerDec 7, 2017
  4. 0/7 reroll of cc/skip-to-optional-valJunio C Hamano, Dec 7, 2017
  5. 6/7 t4045: reindent to make helpers readableJunio C Hamano, Dec 7, 2017
  6. 7/7 t4045: test 'diff --relative' for realJunio C Hamano, Dec 7, 2017
  7. Jacob KellerDec 7, 2017
  8. 5/7 diff: use skip-to-optional-val in parsing --relativeJunio C Hamano, Dec 7, 2017
  9. Jacob KellerDec 7, 2017
  10. Jeff KingDec 7, 2017
  11. Junio C HamanoDec 7, 2017
  12. Jeff KingDec 7, 2017
  13. Junio C HamanoDec 7, 2017
  14. Jeff KingDec 8, 2017
  15. Junio C HamanoDec 8, 2017

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.