Re: bug:git-check-ignore exit status is wrong for negative patterns when -v option used

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

 



On 27/04/21 23.30, Jeremy Faith wrote:
Hi,

git version 2.31.1.362.g311531c9de
git-check-ignore
When a negative pattern is the last .gitignore match the -v option causes the exit status to be 0 rather than the expected 1.
e.g say .gitignore contains  one line: !hello
git check-ignore hello #outputs nothing
echo $?  #shows correct exit status=1 i.e None of the provided paths are ignored.
but
git check-ignore -v hello #output is next line
.gitignore:4:!hello	hello
echo $?  #shows wrong exit status=0 i.e. One or more of the provided paths is ignored

Following change seems to fix it for me
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -114,7 +114,7 @@ static int check_ignore(struct dir_struct *dir,
                 }
                 if (!quiet && (pattern || show_non_matching))
                         output_pattern(pathspec.items[i].original, pattern);
-               if (pattern)
+               if (pattern && !(pattern->flags & PATTERN_FLAG_NEGATIVE))
                         num_ignored++;
         }
         free(seen);

I tried to apply this patch from the mbox, but it was corrupted, so I had to
manually write the changes above. I tested that with your reproduction case and
it worked as expected.

But anyway, please send the proper patch and (preferentially) with the test
consisting of the reproduction case.

Thanks.

--
An old man doll... just what I always wanted! - Clara



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

  Powered by Linux