{"thread":{"id":"26001","subject":"[BUG] git-add doesn't apply filepatterns to tracked files","startedAt":"2010-12-08T23:01:57Z","lastAt":"2010-12-08T23:27:41Z","messageCount":3,"participants":["Kevin Ballard","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"157646","messageId":"47FCD78C-5D8C-4FA5-88DC-26FDCC7361AD@sb.org","threadId":"26001","inReplyTo":null,"subject":"[BUG] git-add doesn't apply filepatterns to tracked files","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-12-08T23:01:57Z","receivedAt":"2010-12-08T23:01:57Z","isPatch":false,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"Ran across a rather bizarre bug today while trying to help someone in #git.\nIt seems that git-add doesn't match filepatterns against tracked files,\nonly against untracked files. Other tested commands (such as git-rm and\ngit-ls-files) are happy to match tracked files, but not git-add.\n\n% git --version\ngit version 1.7.3.3.576.gd872\n% ls -a\n./       ../      .git/    bar.txt  foo.txt\n% git status --short\n M foo.txt\n?? bar.txt\n% git add '*.txt'\n% git status --short\nA  bar.txt\n M foo.txt\n\nThere are no .gitignores in play here.\n\nI haven't had time to investigate the source yet, as I'm still at work.\n\n-Kevin Ballard\n"},{"id":"157647","messageId":"7vipz3j228.fsf@alter.siamese.dyndns.org","threadId":"26001","inReplyTo":"47FCD78C-5D8C-4FA5-88DC-26FDCC7361AD@sb.org","subject":"Re: [BUG] git-add doesn't apply filepatterns to tracked files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-08T23:07:59Z","receivedAt":"2010-12-08T23:07:59Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kevin Ballard <kevin@sb.org> writes:\n\n> It seems that git-add doesn't match filepatterns against tracked files,\n\nThis is an issue known for a long time (and the one I had been bitching\nabout every time I had a chance).  Tracked ones obey diff-index pathspec\nrules (leading path match only) while untracked ones use gitignore\npathspec rules.\n"},{"id":"157649","messageId":"3A1EAFC5-8D24-4E4F-B1BB-B1E153964EB0@sb.org","threadId":"26001","inReplyTo":"7vipz3j228.fsf@alter.siamese.dyndns.org","subject":"Re: [BUG] git-add doesn't apply filepatterns to tracked files","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-12-08T23:27:41Z","receivedAt":"2010-12-08T23:27:41Z","isPatch":false,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"On Dec 8, 2010, at 3:07 PM, Junio C Hamano wrote:\n\n> Kevin Ballard <kevin@sb.org> writes:\n> \n>> It seems that git-add doesn't match filepatterns against tracked files,\n> \n> This is an issue known for a long time (and the one I had been bitching\n> about every time I had a chance).  Tracked ones obey diff-index pathspec\n> rules (leading path match only) while untracked ones use gitignore\n> pathspec rules.\n\nIf I understand you correctly, you're saying tracked files don't understand\npatterns because git-diff-index doesn't handle patterns? Is there some reason\nthat git-diff-index doesn't support patterns? I tried a handful of commands\nand here's the pattern-matching behavior I saw:\n\ngit-add: patterns match untracked, but not tracked\ngit-rm: patterns match tracked files, command doesn't work on untracked\ngit-status: patterns match untracked, but not tracked\ngit-ls-files: patterns match tracked, command doesn't work on untracked\ngit-ls-tree: no pattern support\ngit-check-attr: no pattern support\n\nDocumentation is a bit sporadic here as well. git-add lists <filepattern>\nin its synopsis and options and defines this as supporting\n\"fileglobs\". No mention whatsoever of the tracked file limitation.\ngit-rm only lists <file> in synopsis/options, but does document this\nas being a \"fileglob\". git-status uses <pathspec> in the synopsis, and\ndoesn't even document this in the options. It only makes a reference\nin the description, calling it \"paths\". git-ls-files calls it <file>\nin both synopsis and options, and makes no mention whatsoever of globs.\ngit-ls-tree uses <path> in both synopsis/options, but explicitly claims\nthat this is really a pattern in the option documentation. Curious,\ngiven its complete lack of pattern matching. git-check-attr uses\n<list-of-paths> in the synopsis, with no mention in the options.\n\nOverall, there's a few problems here. The first is that git-add and\ngit-ls-files apply the git-diff-index rules for tracked files, but\napply actual patterns to untracked files. The second is the documentation\nis inconsistent, both in the name of the argument, and in making it\nclear which commands actually support patterns (plus the documentation\nfor git-ls-tree is explicitly wrong about pattern support). The third\nis we're inconsistent in which commands support patterns at all.\n\n-Kevin Ballard\n"}]}