aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2009-04-28 23:21:01 -0400
committerJunio C Hamano <gitster@pobox.com>2009-05-09 08:27:11 -0700
commit07d7bedda8d18ffbfe5960ce27b73a24c01cac1a (patch)
treec5a359d8fea474ec03662eff156162f2c9d61f0a
parentec00d6e0038e030cf73182374e21025c2776cb23 (diff)
downloadgit-07d7bedda8d18ffbfe5960ce27b73a24c01cac1a.tar.gz
git-07d7bedda8d18ffbfe5960ce27b73a24c01cac1a.tar.xz
add: don't complain when adding empty project root
We try to warn the user if one of their pathspecs caused no matches, as it may have been a typo. However, we disable the warning if the pathspec points to an existing file, since that means it is not a typo but simply an empty directory. Unfortunately, the file_exists() test was broken for one special case: the pathspec of the project root is just "". This patch detects this special case and acts as if the file exists (which it must, since it is the project root). The user-visible effect is that this: $ mkdir repo && cd repo && git init && git add . used to complain like: fatal: pathspec '' did not match any files but now is a silent no-op. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin-add.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin-add.c b/builtin-add.c
index cb67d2c17..ad889aac5 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -61,7 +61,7 @@ static void prune_directory(struct dir_struct *dir, const char **pathspec, int p
fill_pathspec_matches(pathspec, seen, specs);
for (i = 0; i < specs; i++) {
- if (!seen[i] && !file_exists(pathspec[i]))
+ if (!seen[i] && pathspec[i][0] && !file_exists(pathspec[i]))
die("pathspec '%s' did not match any files",
pathspec[i]);
}