All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUG] git-add doesn't apply filepatterns to tracked files
@ 2010-12-08 23:01 Kevin Ballard
  2010-12-08 23:07 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Ballard @ 2010-12-08 23:01 UTC (permalink / raw)
  To: git list

Ran across a rather bizarre bug today while trying to help someone in #git.
It seems that git-add doesn't match filepatterns against tracked files,
only against untracked files. Other tested commands (such as git-rm and
git-ls-files) are happy to match tracked files, but not git-add.

% git --version
git version 1.7.3.3.576.gd872
% ls -a
./       ../      .git/    bar.txt  foo.txt
% git status --short
 M foo.txt
?? bar.txt
% git add '*.txt'
% git status --short
A  bar.txt
 M foo.txt

There are no .gitignores in play here.

I haven't had time to investigate the source yet, as I'm still at work.

-Kevin Ballard

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BUG] git-add doesn't apply filepatterns to tracked files
  2010-12-08 23:01 [BUG] git-add doesn't apply filepatterns to tracked files Kevin Ballard
@ 2010-12-08 23:07 ` Junio C Hamano
  2010-12-08 23:27   ` Kevin Ballard
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2010-12-08 23:07 UTC (permalink / raw)
  To: Kevin Ballard; +Cc: git list

Kevin Ballard <kevin@sb.org> writes:

> It seems that git-add doesn't match filepatterns against tracked files,

This is an issue known for a long time (and the one I had been bitching
about every time I had a chance).  Tracked ones obey diff-index pathspec
rules (leading path match only) while untracked ones use gitignore
pathspec rules.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BUG] git-add doesn't apply filepatterns to tracked files
  2010-12-08 23:07 ` Junio C Hamano
@ 2010-12-08 23:27   ` Kevin Ballard
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Ballard @ 2010-12-08 23:27 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git list

On Dec 8, 2010, at 3:07 PM, Junio C Hamano wrote:

> Kevin Ballard <kevin@sb.org> writes:
> 
>> It seems that git-add doesn't match filepatterns against tracked files,
> 
> This is an issue known for a long time (and the one I had been bitching
> about every time I had a chance).  Tracked ones obey diff-index pathspec
> rules (leading path match only) while untracked ones use gitignore
> pathspec rules.

If I understand you correctly, you're saying tracked files don't understand
patterns because git-diff-index doesn't handle patterns? Is there some reason
that git-diff-index doesn't support patterns? I tried a handful of commands
and here's the pattern-matching behavior I saw:

git-add: patterns match untracked, but not tracked
git-rm: patterns match tracked files, command doesn't work on untracked
git-status: patterns match untracked, but not tracked
git-ls-files: patterns match tracked, command doesn't work on untracked
git-ls-tree: no pattern support
git-check-attr: no pattern support

Documentation is a bit sporadic here as well. git-add lists <filepattern>
in its synopsis and options and defines this as supporting
"fileglobs". No mention whatsoever of the tracked file limitation.
git-rm only lists <file> in synopsis/options, but does document this
as being a "fileglob". git-status uses <pathspec> in the synopsis, and
doesn't even document this in the options. It only makes a reference
in the description, calling it "paths". git-ls-files calls it <file>
in both synopsis and options, and makes no mention whatsoever of globs.
git-ls-tree uses <path> in both synopsis/options, but explicitly claims
that this is really a pattern in the option documentation. Curious,
given its complete lack of pattern matching. git-check-attr uses
<list-of-paths> in the synopsis, with no mention in the options.

Overall, there's a few problems here. The first is that git-add and
git-ls-files apply the git-diff-index rules for tracked files, but
apply actual patterns to untracked files. The second is the documentation
is inconsistent, both in the name of the argument, and in making it
clear which commands actually support patterns (plus the documentation
for git-ls-tree is explicitly wrong about pattern support). The third
is we're inconsistent in which commands support patterns at all.

-Kevin Ballard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-08 23:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-08 23:01 [BUG] git-add doesn't apply filepatterns to tracked files Kevin Ballard
2010-12-08 23:07 ` Junio C Hamano
2010-12-08 23:27   ` Kevin Ballard

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.