Skip to content

Commit 1e7ef74

Browse files
cpackhamgitster
authored andcommitted
test for add with non-existent pathspec
Add a test for 'git add -u pathspec' and 'git add pathspec' where pathspec does not exist. The expected result is that git add exits with an error message and an appropriate exit code. Signed-off-by: Chris Packham <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 81f45e7 commit 1e7ef74

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

t/t2200-add-update.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,9 @@ test_expect_success 'add -u resolves unmerged paths' '
176176
177177
'
178178

179+
test_expect_success '"add -u non-existent" should fail' '
180+
test_must_fail git add -u non-existent &&
181+
! (git ls-files | grep "non-existent")
182+
'
183+
179184
test_done

t/t3700-add.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,9 @@ test_expect_success 'git add to resolve conflicts on otherwise ignored path' '
255255
git add track-this
256256
'
257257

258+
test_expect_success '"add non-existent" should fail' '
259+
test_must_fail git add non-existent &&
260+
! (git ls-files | grep "non-existent")
261+
'
262+
258263
test_done

0 commit comments

Comments
 (0)