Commit 959ba670 authored by Jeff King's avatar Jeff King Committed by Junio C Hamano

commit: discard index after setting up partial commit

There may still be some entries from the original index that
should be discarded before we show the status. In
particular, if a file was added in the index but not
included in the partial commit, it would still show up in
the status listing as staged for commit.

Ultimately the correct fix is to keep the two states in
separate index_state variables. Then we can avoid having
to reload the cache from the temporary file altogether, and
just point wt_status_print at the correct index.
Signed-off-by: default avatarJeff King <[email protected]>
Signed-off-by: default avatarJunio C Hamano <[email protected]>
parent 1fe32cb9
......@@ -317,6 +317,10 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
if (write_cache(fd, active_cache, active_nr) ||
die("unable to write temporary index file");
return false_lock.filename;
......@@ -128,4 +128,25 @@ test_expect_success 'status without relative paths' '
cat <<EOF >expect
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
# modified: dir1/modified
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
# dir1/untracked
# dir2/
# expect
# output
# untracked
test_expect_success 'status of partial commit excluding new file in index' '
git status dir1/modified >output &&
diff -u expect output
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment