Michael J Gruber <g...@drmicha.warpmail.net> writes: > Matthieu Moy venit, vidit, dixit 28.01.2013 10:16: >> Most git commands that can be used with our without a filepattern are >> tree-wide by default, the filepattern being used to restrict their scope. >> A few exceptions are: 'git grep', 'git clean', 'git add -u' and 'git add -A'. > > Since I didn't follow this thread, my first reaction was: "Huh? Aren't > they treewide?" (for the relative tree) > > So, for someone reading just the commit message, it would be helpful to > say what the others do, i.e. default to the relative tree at pwd (rather > than defaulting to an empty tree, or all files whether tracked or not, > or...).
I think "add -u && commit" vs "commit -a" you brought up is a good thing to mention, so let's do this. Another tweak is that I did s/filepattern/pathspec/ here. I know that both the documentation and the help text for "git add" say filepattern, but we say pathspec starting from glossary fairly consistently everywhere in the rest of the system. We should probably update the documentation/help for "git add", but that is entirely a separate topic. add: warn when -u or -A is used without pathspec Most Git commands that can be used with or without pathspec operate tree-wide by default, the pathspec being used to restrict their scope. A few exceptions are: 'git grep', 'git clean', 'git add -u' and 'git add -A'. When run in a subdirectory without pathspec, they operate only on paths in the current directory. The inconsistency of 'git add -u' and 'git add -A' are particularly problematic since other 'git add' subcommands (namely 'git add -p' and 'git add -e') are tree-wide by default. It also means that "git add -u && git commit" will record a state that is different from what is recorded with "git commit -a". Flipping the default now is unacceptable, so let's start training users to type 'git add -u|-A :/' or 'git add -u|-A .' explicitly, to prepare for the next steps: * forbid 'git add -u|-A' without pathspec (like 'git add' without option) * much later, maybe, re-allow 'git add -u|-A' without pathspec, that will add all tracked and modified files, or all files, tree-wide. A nice side effect of this patch is that it makes the :/ magic pathspec easier to discover for users. When the command is called from the root of the tree, there is no ambiguity and no need to change the behavior, hence no need to warn. Signed-off-by: Matthieu Moy <matthieu....@imag.fr> Signed-off-by: Junio C Hamano <gits...@pobox.com> -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html