diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-09-18 17:58:04 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-09-18 17:58:04 -0700 |
commit | 694e517778243256b748819cc60eff6011238a0a (patch) | |
tree | 4692698c62330278df6d55a94fa1bc33044eb667 | |
parent | Merge branch 'pw/add-p-leakfix' (diff) | |
parent | add--interactive.perl: specify --no-color explicitly (diff) | |
download | tgif-694e517778243256b748819cc60eff6011238a0a.tar.xz |
Merge branch 'jk/add-i-fixes'
"add -i/-p" fixes.
* jk/add-i-fixes:
add--interactive.perl: specify --no-color explicitly
add-patch: fix inverted return code of repo_read_index()
-rw-r--r-- | add-patch.c | 2 | ||||
-rwxr-xr-x | git-add--interactive.perl | 2 | ||||
-rwxr-xr-x | t/t3701-add-interactive.sh | 8 |
3 files changed, 10 insertions, 2 deletions
diff --git a/add-patch.c b/add-patch.c index 2fcab983a6..cd5cfc93fa 100644 --- a/add-patch.c +++ b/add-patch.c @@ -1655,7 +1655,7 @@ soft_increment: NULL, 0, NULL, 0)) error(_("'git apply' failed")); } - if (!repo_read_index(s->s.r)) + if (repo_read_index(s->s.r) >= 0) repo_refresh_and_write_index(s->s.r, REFRESH_QUIET, 0, 1, NULL, NULL, NULL); } diff --git a/git-add--interactive.perl b/git-add--interactive.perl index f36c0078ac..b6cdcfef61 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -714,7 +714,7 @@ sub parse_diff { if (defined $patch_mode_revision) { push @diff_cmd, get_diff_reference($patch_mode_revision); } - my @diff = run_cmd_pipe("git", @diff_cmd, "--", $path); + my @diff = run_cmd_pipe("git", @diff_cmd, qw(--no-color --), $path); my @colored = (); if ($diff_use_color) { my @display_cmd = ("git", @diff_cmd, qw(--color --), $path); diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index fb73a847cb..1590cf6b98 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -569,12 +569,20 @@ test_expect_success 'patch mode ignores unmerged entries' ' diff_cmp expected diff ' +test_expect_success 'index is refreshed after applying patch' ' + git reset --hard && + echo content >test && + printf y | git add -p && + git diff-files --exit-code +' + test_expect_success 'diffs can be colorized' ' git reset --hard && echo content >test && printf y >y && force_color git add -p >output 2>&1 <y && + git diff-files --exit-code && # We do not want to depend on the exact coloring scheme # git uses for diffs, so just check that we saw some kind of color. |