提交 64ed07ce 编写于 作者: N Nguyễn Thái Ngọc Duy 提交者: Junio C Hamano

add: don't complain when adding empty project root

This behavior was added in 07d7bedd (add: don't complain when adding
empty project root - 2009-04-28) then broken by 84b8b5d1 (remove
match_pathspec() in favor of match_pathspec_depth() -
2013-07-14). Reinstate it.
Noticed-by: NThomas Ferris Nicolaisen <tfnico@gmail.com>
Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 d2446dfd
......@@ -544,7 +544,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
for (i = 0; i < pathspec.nr; i++) {
const char *path = pathspec.items[i].match;
if (!seen[i] &&
if (!seen[i] && path[0] &&
((pathspec.items[i].magic &
(PATHSPEC_GLOB | PATHSPEC_ICASE)) ||
!file_exists(path))) {
......
......@@ -272,6 +272,25 @@ test_expect_success '"add non-existent" should fail' '
! (git ls-files | grep "non-existent")
'
test_expect_success 'git add -A on empty repo does not error out' '
rm -fr empty &&
git init empty &&
(
cd empty &&
git add -A . &&
git add -A
)
'
test_expect_success '"git add ." in empty repo' '
rm -fr empty &&
git init empty &&
(
cd empty &&
git add .
)
'
test_expect_success 'git add --dry-run of existing changed file' "
echo new >>track-this &&
git add --dry-run track-this >actual 2>&1 &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册