@matheusbsbs / matheus-bagliano / commits / dad25e4a7c
Fork 0

Add a config option to ignore errors for git-add

Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alex Riesen committed May 12, 2008 at 19:59 UTC dad25e4a7c34a3ece1355f84b8c4661438754531
2 files changed +31 -1
builtin-add.c
+10 -1
@@ -206,6 +206,15 @@ static struct option builtin_add_options[] = {
206 OPT_END(),
207 };
208
209 +static int add_config(const char *var, const char *value)
210 +{
211 + if (!strcasecmp(var, "add.ignore-errors")) {
212 + ignore_add_errors = git_config_bool(var, value);
213 + return 0;
214 + }
215 + return git_default_config(var, value);
216 +}
217 +
218 int cmd_add(int argc, const char **argv, const char *prefix)
219 {
220 int exit_status = 0;
@@ -220,7 +229,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
229 if (add_interactive)
230 exit(interactive_add(argc, argv, prefix));
231
223 - git_config(git_default_config);
232 + git_config(add_config);
233
234 newfd = hold_locked_index(&lock_file, 1);
235
t/t3700-add.sh
+21
@@ -201,4 +201,25 @@ test_expect_success 'git add --ignore-errors' '
201
202 rm -f foo2
203
204 +test_expect_success 'git add (add.ignore-errors)' '
205 + git config add.ignore-errors 1 &&
206 + git reset --hard &&
207 + date >foo1 &&
208 + date >foo2 &&
209 + chmod 0 foo2 &&
210 + test_must_fail git add --verbose . &&
211 + git ls-files foo1 | grep foo1
212 +'
213 +rm -f foo2
214 +
215 +test_expect_success 'git add (add.ignore-errors = false)' '
216 + git config add.ignore-errors 0 &&
217 + git reset --hard &&
218 + date >foo1 &&
219 + date >foo2 &&
220 + chmod 0 foo2 &&
221 + test_must_fail git add --verbose . &&
222 + ! ( git ls-files foo1 | grep foo1 )
223 +'
224 +
225 test_done