All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shoaib Meenai <smeenai@fb.com>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: [BUG] ** glob pattern in git diff doesn't match root directory
Date: Sat, 24 Apr 2021 02:52:21 +0000	[thread overview]
Message-ID: <79834D18-EAF4-4748-9B96-38AAA0760499@fb.com> (raw)

Hi all,

When I use a `**/` glob pattern with `git diff`, it doesn't seem to
match in the root directory. The documentation for gitgnore says that a
leading `**/` should match in all directories, and I would expect it to
behave the same way for `git diff`. For example:

$ git --version
git version 2.31.1.527.g47e6f16901 # built from the `next` branch
$ mkdir /tmp/globtest && cd /tmp/globtest
$ git init
$ echo foo > foo
$ mkdir sub
$ echo subfoo > sub/foo
$ git add .
$ git commit -m 'Initial commit'
$ echo bar > foo
$ echo subbar > sub/foo
$ git --no-pager diff '**/foo'
diff --git a/sub/foo b/sub/foo
index ef7889f..2b2ab6c 100644
--- a/sub/foo
+++ b/sub/foo
@@ -1 +1 @@
-subfoo
+subbar

Only the diff to `sub/foo` is printed, whereas I'd expect the change to
the top-level `foo` to be printed as well. `git diff '**foo'` does behave
as I would expect. This also happens with a `**` in the middle of a
pattern; e.g., `sub/**/bar` will match `sub/dir/bar` but not `sub/bar`.

Am I misunderstanding how `**` should work, or is this a bug?

Thanks,
Shoaib


             reply	other threads:[~2021-04-24  3:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-24  2:52 Shoaib Meenai [this message]
2021-04-24  3:31 ` [BUG] ** glob pattern in git diff doesn't match root directory Felipe Contreras
2021-04-26  8:23   ` =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason
2021-04-27 19:58     ` Felipe Contreras
2021-04-26 20:45   ` Shoaib Meenai
2021-04-26  8:23 ` =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason
2021-04-26 20:48   ` Shoaib Meenai

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=79834D18-EAF4-4748-9B96-38AAA0760499@fb.com \
    --to=smeenai@fb.com \
    --cc=git@vger.kernel.org \
    /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.