Skip to contentSkip to conversation

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

DISCUSSION Matthieu Moy 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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,

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
#1 lore raw
Quoted 1 line · Matthieu Moy

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.

#2 lore raw
Quoted 5 lines · Junio C Hamano

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: <[email protected]>
	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

#3 lore raw
In reply to Junio C Hamano
Quoted 4 lines · Junio C Hamano
Quoted 1 line · Matthieu Moy

It this the intended behavior? If so, what's the rationale for this?

Quoted 8 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.

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

OK, that answers my question.

Thanks,

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/