git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Christophe Bliard <christophe.bliard@trux.info>
To: git@vger.kernel.org
Cc: "Rafael Ascensão" <rafa.almas@gmail.com>
Subject: Re: bug?: git grep HEAD with exclude in pathspec not taken into account
Date: Wed, 24 Oct 2018 16:53:49 +0200	[thread overview]
Message-ID: <CAGOLd-5Gbt6fQTvm+7018uX+8WF7NUWpa1sFWAg3-5bxtmOt-Q@mail.gmail.com> (raw)
In-Reply-To: <CAGOLd-7Hi+tssj4ozKPd04squ-PuFwtt6f2nhbZp-zKwy62pVQ@mail.gmail.com>

Hi,

I observed an unexpected behavior while using git grep with both git
2.19.1 and 2.14.3. Here is how to reproduce it:

> git init
Initialized empty Git repository in /private/tmp/hello/.git/
> echo foo > fileA
> echo 'foo is false+' > fileB
> git add fileA
> git commit -m fileA
[master (root-commit) f2c83e7] fileA
 1 file changed, 1 insertion(+)
 create mode 100644 fileA
> git add fileB
> git commit -m fileB
[master e35df26] fileB
 1 file changed, 1 insertion(+)
 create mode 100644 fileB
> git --no-pager grep foo HEAD -- ':!fileA'
HEAD:fileB:foo is false+
> git --no-pager grep foo HEAD -- ':!fileB'
HEAD:fileA:foo
HEAD:fileB:foo is false+

In the last command, fileB appears in grep results but it should have
been excluded.

If the HEAD parameter is removed, it works as expected:

> git --no-pager grep foo -- ':!fileB'
fileA:foo

If giving the revision, it does not work either

> git --no-pager grep foo e35df26 -- ':!fileB'
e35df26:fileA:foo
e35df26:fileB:foo is false+

The same behavior can be seen with git archive:

> git archive --verbose master ':(top)'
fileA
fileB
pax_global_header00006660000000000000000000000064133641017230014512gustar00rootroot0000000000000052
comment=e35df26c65f3c0b303e78743496598b8b6a566e9
fileA000066400000000000000000000000041336410172300120130ustar00rootroot00000000000000foo
fileB000066400000000000000000000000161336410172300120170ustar00rootroot00000000000000foo
is false+
> /usr/local/bin/git archive --verbose master ':(top)' ':(exclude)fileA'
fileB
pax_global_header00006660000000000000000000000064133641017230014512gustar00rootroot0000000000000052
comment=e35df26c65f3c0b303e78743496598b8b6a566e9
fileB000066400000000000000000000000161336410172300120170ustar00rootroot00000000000000foo
is false+
> /usr/local/bin/git archive --verbose master ':(top)' ':(exclude)fileB'
fileA
fileB
pax_global_header00006660000000000000000000000064133641017230014512gustar00rootroot0000000000000052
comment=e35df26c65f3c0b303e78743496598b8b6a566e9
fileA000066400000000000000000000000041336410172300120130ustar00rootroot00000000000000foo
fileB000066400000000000000000000000161336410172300120170ustar00rootroot00000000000000foo
is false+

fileA can be excluded, but not fileB.

Is it a bug?

Thanks

--
Christophe Bliard

       reply	other threads:[~2018-10-24 14:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAGOLd-7Hi+tssj4ozKPd04squ-PuFwtt6f2nhbZp-zKwy62pVQ@mail.gmail.com>
2018-10-24 14:53 ` Christophe Bliard [this message]
2018-10-24 15:14   ` bug?: git grep HEAD with exclude in pathspec not taken into account Duy Nguyen
2018-10-24 15:39     ` Christophe Bliard
2018-10-27 14:57   ` Duy Nguyen
2018-11-03 15:30   ` [PATCH] tree-walk.c: fix overoptimistic inclusion in :(exclude) matching Nguyễn Thái Ngọc Duy
2018-11-04  0:25     ` Eric Sunshine
2018-11-04  6:27       ` Eric Sunshine
2018-11-04  6:29         ` Duy Nguyen
2018-11-04  5:28     ` [PATCH v2] " Nguyễn Thái Ngọc Duy
2018-11-05  1:50       ` 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CAGOLd-5Gbt6fQTvm+7018uX+8WF7NUWpa1sFWAg3-5bxtmOt-Q@mail.gmail.com \
    --to=christophe.bliard@trux.info \
    --cc=git@vger.kernel.org \
    --cc=rafa.almas@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).