threads / bug / 20975

Behavior of 'git add \*.txt': bug or feature?

Subject: Behavior of 'git add \*.txt': bug or feature?

## tl;dr

4 messages between Sep 16, 2009 and Sep 17, 2009.

replies: 3people: 3as markdown or json

Matthieu Moy· Sep 16, 2009, 19:46 UTC · lore
Hi,

I find the behavior of 'git add \*.txt' strange: for adding untracked files, it considers \*.txt as a pattern to match, but for updating existing file's staged content, it seems to consider it as a filename:

$ git status # On branch master # Changed but not updated: # # modified: three.txt # modified: two.txt # # Untracked files: # # one.txt no changes added to commit (use "git add" and/or "git commit -a") $ git add -v '*.txt' add 'one.txt' $ git add -v '*.txt' $

I would have expected this "git add -v '*.txt'" to update the staged content of two.txt and three.txt too.

It this the intended behavior? If so, what's the rationale for this?
Thanks,
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Junio C Hamano· Sep 16, 2009, 20:30 UTC · re: Matthieu Moy · lore

Re: Behavior of 'git add \*.txt': bug or feature?

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
> It this the intended behavior? If so, what's the rationale for this?

I strongly suspect that it comes from the fact that we have two definitions and three implementations of pathspec-aware tree traversal. One family is unaware of shell-glob wildcards (they only do leading directory path match) while the other know both leading directory path and shell-glob.

It is on the list of long-term items to fix, as the change required is quite involved.

Matthieu Moy· Sep 16, 2009, 21:26 UTC · re: Junio C Hamano · lore

Re: Behavior of 'git add \*.txt': bug or feature?

Junio C Hamano <gitster@pobox.com> writes:
Show 12 quoted lines
> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>
>> It this the intended behavior? If so, what's the rationale for this?
>
> I strongly suspect that it comes from the fact that we have two
> definitions and three implementations of pathspec-aware tree traversal.
> One family is unaware of shell-glob wildcards (they only do leading
> directory path match) while the other know both leading directory path and
> shell-glob.
>
> It is on the list of long-term items to fix, as the change required is
> quite involved.
OK, that answers my question.
Thanks,
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Clemens Buchacher· Sep 17, 2009, 14:25 UTC · re: Junio C Hamano · lore

Re: Behavior of 'git add \*.txt': bug or feature?

On Wed, Sep 16, 2009 at 01:30:15PM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> I strongly suspect that it comes from the fact that we have two
> definitions and three implementations of pathspec-aware tree traversal.
> One family is unaware of shell-glob wildcards (they only do leading
> directory path match) while the other know both leading directory path and
> shell-glob.
We had a discussion about this in January:
	Subject: Re: [PATCH 3/3] implement pattern matching in ce_path_match
	Message-ID: <7vljtd20m6.fsf@gitster.siamese.dyndns.org>
	http://article.gmane.org/gmane.comp.version-control.git/105679

I was going to fix it, but motivation left me after the above discussion, since I don't really care about this feature.

Clemens

← back to recent threads