@matheusbsbs / matheus-bagliano / commits / 959ba670ad
Fork 0

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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Feb 14, 2008 at 12:18 UTC 959ba670ad7173bcb73afaca69625a5635f63b8b
2 files changed +25
builtin-commit.c
+4
@@ -317,6 +317,10 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
317 if (write_cache(fd, active_cache, active_nr) ||
318 close_lock_file(&false_lock))
319 die("unable to write temporary index file");
320 +
321 + discard_cache();
322 + read_cache_from(false_lock.filename);
323 +
324 return false_lock.filename;
325 }
326
t/t7502-status.sh
+21
@@ -128,4 +128,25 @@ test_expect_success 'status without relative paths' '
128
129 '
130
131 +cat <<EOF >expect
132 +# On branch master
133 +# Changes to be committed:
134 +# (use "git reset HEAD <file>..." to unstage)
135 +#
136 +# modified: dir1/modified
137 +#
138 +# Untracked files:
139 +# (use "git add <file>..." to include in what will be committed)
140 +#
141 +# dir1/untracked
142 +# dir2/
143 +# expect
144 +# output
145 +# untracked
146 +EOF
147 +test_expect_success 'status of partial commit excluding new file in index' '
148 + git status dir1/modified >output &&
149 + diff -u expect output
150 +'
151 +
152 test_done