All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bagas Sanjaya <bagasdotme@gmail.com>
To: Jeremy Faith <jeremy.faith@jci.com>
Cc: Git Users <git@vger.kernel.org>
Subject: Re: bug:git-check-ignore exit status is wrong for negative patterns when -v option used
Date: Wed, 28 Apr 2021 13:15:32 +0700	[thread overview]
Message-ID: <3ea4e4c8-9723-4af6-5f07-9141c3001986@gmail.com> (raw)
In-Reply-To: <CY4P132MB00885C970ACF5A277F06E40385419@CY4P132MB0088.NAMP132.PROD.OUTLOOK.COM>

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

  reply	other threads:[~2021-04-28  6:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 16:30 bug:git-check-ignore exit status is wrong for negative patterns when -v option used Jeremy Faith
2021-04-28  6:15 ` Bagas Sanjaya [this message]
2021-04-29 14:26   ` Jeremy Faith
2021-04-28  7:13 ` Junio C Hamano
2021-04-29 14:10   ` Jeremy Faith
2021-04-30  0:22     ` Junio C Hamano
2021-04-30  9:56       ` Jeremy Faith
2021-04-30 20:51         ` Elijah Newren
2021-05-03  3:09         ` 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=3ea4e4c8-9723-4af6-5f07-9141c3001986@gmail.com \
    --to=bagasdotme@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jeremy.faith@jci.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.