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

Commit 4ba46c2

Browse files
committed
Merge branch 'nd/add-empty-fix'
"git add -A" (no other arguments) in a totally empty working tree used to emit an error. * nd/add-empty-fix: add: don't complain when adding empty project root
2 parents 0c52457 + 64ed07c commit 4ba46c2

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
@@ -547,7 +547,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
547547
const char *path = pathspec.items[i].match;
548548
if (pathspec.items[i].magic & PATHSPEC_EXCLUDE)
549549
continue;
550-
if (!seen[i] &&
550+
if (!seen[i] && path[0] &&
551551
((pathspec.items[i].magic &
552552
(PATHSPEC_GLOB | PATHSPEC_ICASE)) ||
553553
!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)