Skip to content

Commit

Permalink
Merge branch 'ds/add-i-color-configuration-fix' into next
Browse files Browse the repository at this point in the history
The reimplemented "git add -i" did not honor color.ui configuration.

* ds/add-i-color-configuration-fix:
  add: test use of brackets when color is disabled
  add: check color.ui for interactive add
  • Loading branch information
gitster committed Jun 15, 2023
2 parents e841ad2 + 6f74648 commit 377b9f9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion builtin/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static int add_config(const char *var, const char *value, void *cb)
return 0;
}

return git_default_config(var, value, cb);
return git_color_default_config(var, value, cb);
}

static const char embedded_advice[] = N_(
Expand Down
38 changes: 38 additions & 0 deletions t/t3701-add-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,44 @@ test_expect_success 'colors can be overridden' '
test_cmp expect actual
'

test_expect_success 'brackets appear without color' '
git reset --hard &&
test_when_finished "git rm -f bracket-test" &&
test_write_lines context old more-context >bracket-test &&
git add bracket-test &&
test_write_lines context new more-context another-one >bracket-test &&
test_write_lines quit >input &&
git add -i >actual <input &&
sed "s/^|//" >expect <<-\EOF &&
| staged unstaged path
| 1: +3/-0 +2/-1 bracket-test
|
|*** Commands ***
| 1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked
| 5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elp
|What now> Bye.
EOF
test_cmp expect actual
'

test_expect_success 'colors can be skipped with color.ui=false' '
git reset --hard &&
test_when_finished "git rm -f color-test" &&
test_write_lines context old more-context >color-test &&
git add color-test &&
test_write_lines context new more-context another-one >color-test &&
test_write_lines help quit >input &&
force_color git \
-c color.ui=false \
add -i >actual.raw <input &&
test_decode_color <actual.raw >actual &&
test_cmp actual.raw actual
'

test_expect_success 'colorized diffs respect diff.wsErrorHighlight' '
git reset --hard &&
Expand Down

0 comments on commit 377b9f9

Please sign in to comment.