]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/add.c
git add: start preparing for "git add <pathspec>..." to default to "-A"
authorJunio C Hamano <gitster@pobox.com>
Tue, 19 Apr 2011 19:18:20 +0000 (12:18 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 9 Mar 2013 07:26:56 +0000 (23:26 -0800)
commit45c45e300bcbe493a39533bb04f6bd548e8a3f19
tree5ac08e2d6af81dcbd3c57efdc49e63612bd12640
parent300c0a2209b753da1075770f7b696b1814c010f7
git add: start preparing for "git add <pathspec>..." to default to "-A"

When "git add subdir/" is run without "-u" or "-A" option, e.g.

    $ edit subdir/x
    $ create subdir/y
    $ rm subdir/z
    $ git add subdir/

the command does not notice removal of paths (e.g. subdir/z) from
the working tree.  This sometimes confuses new people, as arguably
"git add" is told to record the current state of "subdir/" as a
whole, not the current state of the paths that exist in the working
tree that matches that pathspec (the latter by definition excludes
the state of "subdir/z" because it does not exist in the working
tree).

Plan to eventually make "git add" pretend as if "-A" is given when
there is a pathspec on the command line.  When resolving a conflict
to remove a path, the current code tells you to "git rm $path", but
with such a change, you will be able to say "git add $path" (of
course you can do "git add -A $path" today).  That means that we can
simplify the advice messages given by "git status".  That all will
be in Git 2.0 or later, if we are going to do so.

For that transition to work, people need to learn either to say "git
add --no-all subdir/" when they want to ignore the removed paths
like "subdir/z", or to say "git add -A subdir/" when they want to
take the state of the directory as a whole.

"git add" without any argument will continue to be a no-op.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-add.txt
builtin/add.c
t/t2200-add-update.sh