# Doing a git add '' will add more files then expected

5 messages from 2014-11-17 to 2014-11-23. Participants: Guilherme, Andreas Schwab, Matthieu Moy, Junio C Hamano, Javier Domingo Cansino.
Thread: https://gitlist.dev/t/37986

## Guilherme, 2014-11-17 16:25

Subject: Doing a git add '' will add more files then expected
Message-ID: <CAMDzUtyhNKdzHQK2zLEutJRcRUibhO-U6Zh0yJhrx-YxBqP5cQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAMDzUtyhNKdzHQK2zLEutJRcRUibhO-U6Zh0yJhrx-YxBqP5cQ%40mail.gmail.com

```
Hello,

I first asked on stackoverflow
(http://stackoverflow.com/questions/26933761/python-sh-module-and-git-try-to-add-more-files-then-in-command/26934517#26934517)
about this behaviour.

Then on the conversation that happened on the git-users mailing list
other agreed that this behaviour is probably not as intended.

Steps to reproduce:
In bash (not sure this is bash specific) do:
git add ''
(that's to apostrophes, an empty argument)

Results
same as doing git add .

Expected
no files added or error about not finding file ''

Hope this helps.
Guilherme

```

## Andreas Schwab, 2014-11-17 18:15

Subject: Re: Doing a git add '' will add more files then expected
Message-ID: <87lhn91ynu.fsf@igel.home>
URL: https://gitlist.dev/e/87lhn91ynu.fsf%40igel.home
In-Reply-To: <CAMDzUtyhNKdzHQK2zLEutJRcRUibhO-U6Zh0yJhrx-YxBqP5cQ@mail.gmail.com>

```
Guilherme <guibufolo@gmail.com> writes:

> Steps to reproduce:
> In bash (not sure this is bash specific) do:
> git add ''
> (that's to apostrophes, an empty argument)
>
> Results
> same as doing git add .
>
> Expected
> no files added or error about not finding file ''

The argument to git add is a pathspec, and the empty pathspec matches
all files.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

```

## Matthieu Moy, 2014-11-17 18:42

Subject: Re: Doing a git add '' will add more files then expected
Message-ID: <vpqa93p8y9n.fsf@anie.imag.fr>
URL: https://gitlist.dev/e/vpqa93p8y9n.fsf%40anie.imag.fr
In-Reply-To: <87lhn91ynu.fsf@igel.home>

```
Andreas Schwab <schwab@linux-m68k.org> writes:

> The argument to git add is a pathspec, and the empty pathspec matches
> all files.

Err, why does the empty pathspec match all files? Isn't that a bug?

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Junio C Hamano, 2014-11-17 19:08

Subject: Re: Doing a git add '' will add more files then expected
Message-ID: <xmqqh9xxy79x.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqh9xxy79x.fsf%40gitster.dls.corp.google.com
In-Reply-To: <vpqa93p8y9n.fsf@anie.imag.fr>

```
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Andreas Schwab <schwab@linux-m68k.org> writes:
>
>> The argument to git add is a pathspec, and the empty pathspec matches
>> all files.
>
> Err, why does the empty pathspec match all files? Isn't that a bug?

That is debatable.

    cd Documentation
    git add "a"

would be equivalent to typing

    git add Documentation/"a"

so

    cd Documentation
    git add ""

would be equivalent to typing

    git add Documentation/""

And doing the same from the top-level of the working tree can be
argued to be a natural extension.

```

## Javier Domingo Cansino, 2014-11-23 19:06

Subject: Re: Doing a git add '' will add more files then expected
Message-ID: <CALZVapkKFOSQptQX2_A5E9Oankk+ZBQYcALNW0OTzu4aARJx2g@mail.gmail.com>
URL: https://gitlist.dev/e/CALZVapkKFOSQptQX2_A5E9Oankk%2BZBQYcALNW0OTzu4aARJx2g%40mail.gmail.com
In-Reply-To: <xmqqh9xxy79x.fsf@gitster.dls.corp.google.com>

```
IMO, if you put an empty string "" you would be implying the same as
with a dot (git add . ).

The important thing is that "git add" without a pathspec returns an
error, as it has always done, mainly because it people tend to work
without gitignoring all the files they should, and allowing such
behaviour would make things harder.

-- 
Javier Domingo Cansino

```
