summaryrefslogtreecommitdiff
path: root/t/t4252/am-test-1-1
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2020-09-07 04:08:53 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-09-08 14:48:29 -0700
commitdc6264157236fb729ad072e18f14d89549c08555 (patch)
treee071f5d9bd0ca3092cbf7d3b1284c7e5d4e18698 /t/t4252/am-test-1-1
parentGit 2.28 (diff)
downloadtgif-dc6264157236fb729ad072e18f14d89549c08555.tar.xz
add-patch: fix inverted return code of repo_read_index()
After applying hunks to a file with "add -p", the C patch_update_file() function tries to refresh the index (just like the perl version does). We can only refresh the index if we're able to read it in, so we first check the return value of repo_read_index(). But unlike many functions, where "0" is success, that function is documented to return the number of entries in the index. Hence we should be checking for success with a non-negative return value. Neither the tests nor any users seem to have noticed this, probably due to a combination of: - this affects only the C version, which is not yet the default - following it up with any porcelain command like "git diff" or "git commit" would refresh the index automatically. But you can see the problem by running the plumbing "git diff-files" immediately after "add -p" stages all hunks. Running the new test with GIT_TEST_ADD_I_USE_BUILTIN=1 fails without the matching code change. Signed-off-by: Jeff King <peff@peff.net> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4252/am-test-1-1')
0 files changed, 0 insertions, 0 deletions