git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tim Henigan <tim.henigan@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, peff@peff.net
Subject: Re: [PATCH v3] diff-no-index: exit(1) if 'diff --quiet <repo file> <external file>' finds changes
Date: Tue, 19 Jun 2012 09:05:40 -0400	[thread overview]
Message-ID: <CAFouethcrw3vOF7SPwHxjH4ABmF8U1df0MfyzcUGq2yTYxs4ow@mail.gmail.com> (raw)
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:
> 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.


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

  reply	other threads:[~2012-06-19 13:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-18 19:28 [PATCH v3] diff-no-index: exit(1) if 'diff --quiet <repo file> <external file>' finds changes Tim Henigan
2012-06-18 19:45 ` Jeff King
2012-06-18 20:09 ` Junio C Hamano
2012-06-19 13:05   ` Tim Henigan [this message]
2012-06-19 13:58     ` Jeff King
2012-06-19 16:47       ` Tim Henigan
2012-06-20 13:38         ` Tim Henigan
2012-06-20 16:06           ` Jeff King
2012-06-20 18:44             ` Junio C Hamano
2012-06-20 18:52               ` Jeff King
2012-06-20 19:21                 ` Junio C Hamano
2012-06-21 15:07             ` Tim Henigan
2012-06-21 16:55               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFouethcrw3vOF7SPwHxjH4ABmF8U1df0MfyzcUGq2yTYxs4ow@mail.gmail.com \
    --to=tim.henigan@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).