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

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

 



On Fri, Jun 15, 2012 at 3:37 PM, Jeff King <peff@xxxxxxxx> wrote:
> On Fri, Jun 15, 2012 at 11:45:47AM -0700, Junio C Hamano wrote:
>
>> I think this breaks a normal case of comparing revisions and tracked
>> contents in a big way.

I didn't understand the ramifications of making the change where I
did.  I appreciate you and Jeff taking the time to point out the
problem (and suggest better solutions).


>> I think the following may be a lot closer to the correct fix; I
>> didn't test many combinations of options with it, though.
>>
>>  diff-no-index.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/diff-no-index.c b/diff-no-index.c
>> index f0b0010..ed74e27 100644
>> --- a/diff-no-index.c
>> +++ b/diff-no-index.c
>> @@ -172,7 +172,7 @@ void diff_no_index(struct rev_info *revs,
>>                  int argc, const char **argv,
>>                  int nongit, const char *prefix)
>>  {
>> -     int i;
>> +     int i, result;
>>       int no_index = 0;
>>       unsigned options = 0;
>>
>> @@ -273,5 +273,6 @@ void diff_no_index(struct rev_info *revs,
>>        * The return code for --no-index imitates diff(1):
>>        * 0 = no changes, 1 = changes, else error
>>        */
>> -     exit(revs->diffopt.found_changes);
>> +     result = !!diff_result_code(&revs->diffopt, 0);
>> +     exit(result);

I assume the '!!' before 'diff_result_code' is a typo.  Reverting my
changes and putting this in solves the problem.

...

> So the patch I posted elsewhere in the thread is not right; we do not
> need to do diff_flush_patch to actually compare, because the
> stat_unmatch code will have done everything we want (unless
> DIFF_FROM_CONTENTS really is set). And the bug is purely one of looking
> at the wrong output flag.

I will send v2 with the change to 'diff-no-index.c' suggested by
Junio.  I will also include the 'test_expect_code' improvement
suggested by Jeff.
--
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]