Skip to content

Commit 0df7b8e

Browse files
committed
git add: avoid "-u/-A without pathspec" warning on stat-dirty paths
In preparation for Git 2.0, "git add -u/-A" without pathspec checks all the working tree (not limited to the current directory) and issues a warning when it finds any path that we might add in Git 2.0, because that would mean the users' fingers need to be trained to explicitly say "." if they want to keep the current behaviour. However, the check was incomplete, because "git add" usually does not refresh the index, considers a path that is stat-dirty but has contents that is otherwise up-to-date in the index as "we might add", and relies on that it is a no-op to add the same thing again via the add_file_to_index() API (which also knows not to say "added" in verbose mode when this happens). We do not want to trigger the warning for a path that is outside the current directory is merely stat-dirty, as it won't be added in Git 2.0, either. Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Jonathan Nieder <jrnieder@gmail.com>
1 parent de91daf commit 0df7b8e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

builtin/add.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
495495
refresh(verbose, pathspec);
496496
goto finish;
497497
}
498+
if (implicit_dot && prefix)
499+
refresh_cache(REFRESH_QUIET);
498500

499501
if (pathspec) {
500502
int i;

0 commit comments

Comments
 (0)