add -u: only show pathless 'add -u' warning when changes exist outside cwd
commit71c7b0538f8f037e49a04f415a6fbf0bba2c85ad
authorJonathan Nieder <jrnieder@gmail.com>
Tue, 19 Mar 2013 22:50:50 +0000 (19 15:50 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Apr 2013 18:34:22 +0000 (3 11:34 -0700)
tree71f7c97f0bd3b7efd3e51134773f7ff569a4e1e8
parent16d41d42184a4c82d2cd8c41e9eef9784cf437b1
add -u: only show pathless 'add -u' warning when changes exist outside cwd

A common workflow in large projects is to chdir into a subdirectory of
interest and only do work there:

cd src
vi foo.c
make test
git add -u
git commit

The upcoming change to 'git add -u' behavior would not affect such a
workflow: when the only changes present are in the current directory,
'git add -u' will add all changes, and whether that happens via an
implicit "." or implicit ":/" parameter is an unimportant
implementation detail.

The warning about use of 'git add -u' with no pathspec is annoying
because it seemingly serves no purpose in this case.  So suppress the
warning unless there are changes outside the cwd that are not being
added.

A previous version of this patch ran two I/O-intensive diff-files
passes: one to find changes outside the cwd, and another to find
changes to add to the index within the cwd.  This version runs one
full-tree diff and decides for each change whether to add it or warn
and suppress it in update_callback.  As a result, even on very large
repositories "git add -u" will not be significantly slower than the
future default behavior ("git add -u :/"), and the slowdown relative
to "git add -u ." should be a useful clue to users of such
repositories to get into the habit of explicitly passing '.'.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Improved-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/add.c
cache.h