Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 64ed07c

Browse files
pcloudsgitster
authored andcommitted
add: don't complain when adding empty project root
This behavior was added in 07d7bed (add: don't complain when adding empty project root - 2009-04-28) then broken by 84b8b5d (remove match_pathspec() in favor of match_pathspec_depth() - 2013-07-14). Reinstate it. Noticed-by: Thomas Ferris Nicolaisen <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Reviewed-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d2446df commit 64ed07c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

builtin/add.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
544544

545545
for (i = 0; i < pathspec.nr; i++) {
546546
const char *path = pathspec.items[i].match;
547-
if (!seen[i] &&
547+
if (!seen[i] && path[0] &&
548548
((pathspec.items[i].magic &
549549
(PATHSPEC_GLOB | PATHSPEC_ICASE)) ||
550550
!file_exists(path))) {

t/t3700-add.sh

+19
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,25 @@ test_expect_success '"add non-existent" should fail' '
272272
! (git ls-files | grep "non-existent")
273273
'
274274

275+
test_expect_success 'git add -A on empty repo does not error out' '
276+
rm -fr empty &&
277+
git init empty &&
278+
(
279+
cd empty &&
280+
git add -A . &&
281+
git add -A
282+
)
283+
'
284+
285+
test_expect_success '"git add ." in empty repo' '
286+
rm -fr empty &&
287+
git init empty &&
288+
(
289+
cd empty &&
290+
git add .
291+
)
292+
'
293+
275294
test_expect_success 'git add --dry-run of existing changed file' "
276295
echo new >>track-this &&
277296
git add --dry-run track-this >actual 2>&1 &&

0 commit comments

Comments
 (0)