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

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

 



On Mon, Jun 18, 2012 at 4:09 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Tim Henigan <tim.henigan@xxxxxxxxx> 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.


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


>> +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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]