From 959ba670ad7173bcb73afaca69625a5635f63b8b Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 14 Feb 2008 12:18:23 -0500 Subject: [PATCH] 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: Jeff King Signed-off-by: Junio C Hamano --- builtin-commit.c | 4 ++++ t/t7502-status.sh | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/builtin-commit.c b/builtin-commit.c index a43f201995..45232a11c4 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -317,6 +317,10 @@ static char *prepare_index(int argc, const char **argv, const char *prefix) if (write_cache(fd, active_cache, active_nr) || close_lock_file(&false_lock)) die("unable to write temporary index file"); + + discard_cache(); + read_cache_from(false_lock.filename); + return false_lock.filename; } diff --git a/t/t7502-status.sh b/t/t7502-status.sh index b64ce30ff1..e00607490b 100755 --- a/t/t7502-status.sh +++ b/t/t7502-status.sh @@ -128,4 +128,25 @@ test_expect_success 'status without relative paths' ' ' +cat <expect +# On branch master +# Changes to be committed: +# (use "git reset HEAD ..." to unstage) +# +# modified: dir1/modified +# +# Untracked files: +# (use "git add ..." to include in what will be committed) +# +# dir1/untracked +# dir2/ +# expect +# output +# untracked +EOF +test_expect_success 'status of partial commit excluding new file in index' ' + git status dir1/modified >output && + diff -u expect output +' + test_done -- 2.11.4.GIT