Skip to content

Commit

Permalink
add: allow configurations to be overriden by command line
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Boyd authored and Junio C Hamano committed Jun 18, 2009
1 parent 90dce51 commit ed342fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions builtin-add.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ int cmd_add(int argc, const char **argv, const char *prefix)
int add_new_files;
int require_pathspec;

git_config(add_config, NULL);

argc = parse_options(argc, argv, builtin_add_options,
builtin_add_usage, 0);
if (patch_interactive)
add_interactive = 1;
if (add_interactive)
exit(interactive_add(argc, argv, prefix));

git_config(add_config, NULL);

if (addremove && take_worktree_changes)
die("-A and -u are mutually incompatible");
if (addremove && !argc) {
Expand Down
13 changes: 13 additions & 0 deletions t/t3700-add.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,19 @@ test_expect_success 'git add (add.ignore-errors = false)' '
test_must_fail git add --verbose . &&
! ( git ls-files foo1 | grep foo1 )
'
rm -f foo2

test_expect_success '--no-ignore-errors overrides config' '
git config add.ignore-errors 1 &&
git reset --hard &&
date >foo1 &&
date >foo2 &&
chmod 0 foo2 &&
test_must_fail git add --verbose --no-ignore-errors . &&
! ( git ls-files foo1 | grep foo1 ) &&
git config add.ignore-errors 0
'
rm -f foo2

test_expect_success 'git add '\''fo\[ou\]bar'\'' ignores foobar' '
git reset --hard &&
Expand Down

0 comments on commit ed342fd

Please sign in to comment.