Skip to content

Commit d0879b3

Browse files
committed
Merge branch 'mg/add-ignore-errors' into maint
* mg/add-ignore-errors: add: ignore only ignored files
2 parents efc028b + 1d31e5a commit d0879b3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

builtin/add.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static int add_files(struct dir_struct *dir, int flags)
284284
for (i = 0; i < dir->ignored_nr; i++)
285285
fprintf(stderr, "%s\n", dir->ignored[i]->name);
286286
fprintf(stderr, _("Use -f if you really want to add them.\n"));
287-
die(_("no files added"));
287+
exit_status = 1;
288288
}
289289

290290
for (i = 0; i < dir->nr; i++)

t/t3700-add.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ test_expect_success 'error out when attempting to add ignored ones without -f' '
9191
! (git ls-files | grep "\\.ig")
9292
'
9393

94+
test_expect_success 'error out when attempting to add ignored ones but add others' '
95+
touch a.if &&
96+
test_must_fail git add a.?? &&
97+
! (git ls-files | grep "\\.ig") &&
98+
(git ls-files | grep a.if)
99+
'
100+
94101
test_expect_success 'add ignored ones with -f' '
95102
git add -f a.?? &&
96103
git ls-files --error-unmatch a.ig
@@ -311,7 +318,6 @@ cat >expect.err <<\EOF
311318
The following paths are ignored by one of your .gitignore files:
312319
ignored-file
313320
Use -f if you really want to add them.
314-
fatal: no files added
315321
EOF
316322
cat >expect.out <<\EOF
317323
add 'track-this'

0 commit comments

Comments
 (0)