Skip to content

Commit

Permalink
Merge branch 'mg/add-ignore-errors' into maint
Browse files Browse the repository at this point in the history
* mg/add-ignore-errors:
  add: ignore only ignored files
  • Loading branch information
Junio C Hamano committed Jan 12, 2015
2 parents efc028b + 1d31e5a commit d0879b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion builtin/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ static int add_files(struct dir_struct *dir, int flags)
for (i = 0; i < dir->ignored_nr; i++)
fprintf(stderr, "%s\n", dir->ignored[i]->name);
fprintf(stderr, _("Use -f if you really want to add them.\n"));
die(_("no files added"));
exit_status = 1;
}

for (i = 0; i < dir->nr; i++)
Expand Down
8 changes: 7 additions & 1 deletion t/t3700-add.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ test_expect_success 'error out when attempting to add ignored ones without -f' '
! (git ls-files | grep "\\.ig")
'

test_expect_success 'error out when attempting to add ignored ones but add others' '
touch a.if &&
test_must_fail git add a.?? &&
! (git ls-files | grep "\\.ig") &&
(git ls-files | grep a.if)
'

test_expect_success 'add ignored ones with -f' '
git add -f a.?? &&
git ls-files --error-unmatch a.ig
Expand Down Expand Up @@ -311,7 +318,6 @@ cat >expect.err <<\EOF
The following paths are ignored by one of your .gitignore files:
ignored-file
Use -f if you really want to add them.
fatal: no files added
EOF
cat >expect.out <<\EOF
add 'track-this'
Expand Down

0 comments on commit d0879b3

Please sign in to comment.