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

add: allow configurations to be overriden by command line

Don't call git_config after parsing the command line options, otherwise the config settings will override any settings made by the command line. This can be seen by setting add.ignore_errors and then specifying --no-ignore-errors when using git-add. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephen Boyd committed Jun 18, 2009 at 02:17 UTC ed342fdea0b7fd466ed3257c5e68aa81c391b782
2 files changed +15 -2
builtin-add.c
+2 -2
@@ -247,6 +247,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
247 int add_new_files;
248 int require_pathspec;
249
250 + git_config(add_config, NULL);
251 +
252 argc = parse_options(argc, argv, builtin_add_options,
253 builtin_add_usage, 0);
254 if (patch_interactive)
@@ -254,8 +256,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
256 if (add_interactive)
257 exit(interactive_add(argc, argv, prefix));
258
257 - git_config(add_config, NULL);
258 -
259 if (addremove && take_worktree_changes)
260 die("-A and -u are mutually incompatible");
261 if (addremove && !argc) {
t/t3700-add.sh
+13
@@ -221,6 +221,19 @@ test_expect_success 'git add (add.ignore-errors = false)' '
221 test_must_fail git add --verbose . &&
222 ! ( git ls-files foo1 | grep foo1 )
223 '
224 +rm -f foo2
225 +
226 +test_expect_success '--no-ignore-errors overrides config' '
227 + git config add.ignore-errors 1 &&
228 + git reset --hard &&
229 + date >foo1 &&
230 + date >foo2 &&
231 + chmod 0 foo2 &&
232 + test_must_fail git add --verbose --no-ignore-errors . &&
233 + ! ( git ls-files foo1 | grep foo1 ) &&
234 + git config add.ignore-errors 0
235 +'
236 +rm -f foo2
237
238 test_expect_success 'git add '\''fo\[ou\]bar'\'' ignores foobar' '
239 git reset --hard &&