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

Re: [PATCH v3] diff-no-index: exit(1) if 'diff --quiet <repo file> <external file>' finds changes

From
Tim Henigan <tim.henigan@gmail.com>
Date
Jun 19, 2012, 13:05 UTC
Message-ID
<CAFouethcrw3vOF7SPwHxjH4ABmF8U1df0MfyzcUGq2yTYxs4ow@mail.gmail.com>
In-Reply-To
<7vr4tc2xhy.fsf@alter.siamese.dyndns.org>
On Mon, Jun 18, 2012 at 4:09 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 11 quoted lines
> Tim Henigan <tim.henigan@gmail.com> writes:
>
>> When running 'git diff --quiet <file1> <file2>', if file1 or file2
>> is outside the repository, it will exit(0) even if the files differ.
>> It should exit(1) when they differ.
>> -     exit(revs->diffopt.found_changes);
>> +     int result = diff_result_code(&revs->diffopt, 0);
>> +     exit(result);
>>  }
>
> Decl-after-stmt.

Will eliminate intermediate variable in v4. Thanks to both you and Jeff for pointing this out.

>> +             echo "1 1" > a &&
>
> Please drop extra SP between ">" and "a".
Will fix in v4.
Show 17 quoted lines
>> +             git add . &&
>> +             git commit -m 1
>> +     ) &&
>> +     mkdir -p test-outside/no-repo && (
>> +             cd test-outside/no-repo &&
>> +             echo "1 1" >a &&
>> +             echo "1 1" >matching-file &&
>> +             echo "1 1 " >trailing-space &&
>> +             echo "1   1" >extra-space &&
>> +             echo "2" >never-match
>> +     )
>
> The inspiration of using CEILING comes from the existing t7810-grep
> test, and I would have preferred if you used the same non/git for a
> non-git repository for easier greppability ("git grep CEIL t/" to
> notice the use of the technique and then "git grep non/git t/" to
> verify, for example).

Okay. I still need the non/git directory to be outside the test repo's path, so the new layout will be:

    $TRASH_DIRECTORY/
        test-outside/
            repo/
            non/git/
This adds an extra layer to the non git paths, but won't cause any problems.
Show 8 quoted lines
>> +test_expect_success 'git diff, one file outside repo' '
>> +     (
>> +             GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
>> +             export GIT_CEILING_DIRECTORIES &&
>
> Do you even need these two lines for this test?  your test runs
> inside test-outside/repo that _is_ a git repository, and that
> repository knows that ../no-repo is not part of it already.

You are correct, CEILING does not need to be set for tests where one file is inside 'test-outside/repo'.

As a side note, I found that these tests fail if a relative path is used for the file in 'non/git'. In other words, this passes:

    test_expect_code 0 git diff --quiet a
"$TRASH_DIRECTORY/test-outside/non/git/matching-file"
but this fails:
    test_expect_code 0 git diff --quiet a ../non/git/matching-file
This surprised me, but I have not investigated any further.
Previous: Junio C HamanoNext: Jeff King
Message 4 of 13 in “diff-no-index: exit(1) if 'diff --quiet <repo file> <external file>' finds changes”
  1. diff-no-index: exit(1) if 'diff --quiet <repo file> <external file>' finds changesTim Henigan, Jun 18, 2012
  2. Jeff KingJun 18, 2012
  3. Junio C HamanoJun 18, 2012
  4. Tim HeniganJun 19, 2012
  5. Jeff KingJun 19, 2012
  6. Tim HeniganJun 19, 2012
  7. Tim HeniganJun 20, 2012
  8. Jeff KingJun 20, 2012
  9. Junio C HamanoJun 20, 2012
  10. Jeff KingJun 20, 2012
  11. Junio C HamanoJun 20, 2012
  12. Tim HeniganJun 21, 2012
  13. Junio C HamanoJun 21, 2012

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.