# Bug (or inconsistency) in git add

3 messages from 2012-04-30 to 2012-04-30. Participants: Steve Bennett, Junio C Hamano.
Thread: https://gitlist.dev/t/30360

## Steve Bennett, 2012-04-30 04:03

Subject: Bug (or inconsistency) in git add
Message-ID: <CADJEhEVNPj_FrRatjD7Jmbd7i_FYg9BzNNP48_4VAr6fgqBT8Q@mail.gmail.com>
URL: https://gitlist.dev/e/CADJEhEVNPj_FrRatjD7Jmbd7i_FYg9BzNNP48_4VAr6fgqBT8Q%40mail.gmail.com
In-Reply-To: <CADJEhEWC=mMManxi9Q6W9EvVKmTV=i1ZxbdW4QS_ou_DrBEb+Q@mail.gmail.com>

```
I couldn't find a bug tracker for Git, so here's my bug report.

Given a directory containing foo/bar/baz/blah.py and
foo/bar/baz/blem.py, this command:
1)
git add foo/**/*.py

produces no output, and adds no files.

This command:
2)
git add /**.py

produces no output but adds all the files.

This command:
3)
git add foo/**.py

produces an error and adds no files.

IMHO, "git add" should always produce an error message if no files
matched the pathspec given. So case 1) should produce an error
message.

git version 1.7.9.4 on Snow Leopard. (There doesn't seem to be a
1.7.10 at http://code.google.com/p/git-osx-installer/downloads/list?can=3)

If this is some weird bash shell behaviour, my apologies.

Steve

```

## Steve Bennett, 2012-04-30 06:46

Subject: Re: Bug (or inconsistency) in git add
Message-ID: <CADJEhEXtDZGav1Y5epZQ69NWptyVyPC1hmN6=YaNYrg3vYmBqg@mail.gmail.com>
URL: https://gitlist.dev/e/CADJEhEXtDZGav1Y5epZQ69NWptyVyPC1hmN6%3DYaNYrg3vYmBqg%40mail.gmail.com
In-Reply-To: <CAA5Ydx9h6o=uppRk5zc9V4z1S831KGVRBzTw9oMqDjY34-noOw@mail.gmail.com>

```
On 30 April 2012 16:23, Victor Engmark <victor.engmark@gmail.com> wrote:
> I can't answer for the absence of an error when no files are added, but
> globbing (resolving * in paths) is done by the shell, not by git. To verify
> a glob, just echo it:
>
> echo foo/**/*.py

Yes, it appears that the two cases are treated differently:
1) foo/**/*.py:  the shell expands the **, and interprets it the same
as "*",  so foo/**/*.py means any python file exactly one directory
deeper than foo
2) /**.py: the shell ignores this and passes it straight to Git.

So I guess the missing error message I reported originally is
logically correct in a kind of convoluted way: the ** is actually
matching real files (just not the ones you expected) and they don't
have any changes, so you don't get any output.

(Whether or not it makes sense for Git to produce identical output in
the case of both adding files with changes, and doing nothing at all,
is a debate I probably shouldn't start...)

> If you want to add recursively, you'll need to enable the special behavior
> for double stars:
>
> shopt -s globstar

Looks like I need a newer version of Bash.

In any case, it looks like Git does support some ** globbing natively.
I'm curious about the rules for that. They don't seem to be documented
in the git man page (http://schacon.github.com/git/user-manual.html).

Steve

```

## Junio C Hamano, 2012-04-30 07:02

Subject: Re: Bug (or inconsistency) in git add
Message-ID: <7vwr4xhfcr.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vwr4xhfcr.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CADJEhEXtDZGav1Y5epZQ69NWptyVyPC1hmN6=YaNYrg3vYmBqg@mail.gmail.com>

```
Steve Bennett <stevage@gmail.com> writes:

> In any case, it looks like Git does support some ** globbing natively.

No, we don't.

```
