diff options
author | Thomas Gummerer <t.gummerer@gmail.com> | 2019-11-13 15:01:36 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-11-14 11:08:25 +0900 |
commit | df53c80822735ddd30638ba77be3face438d5ad8 (patch) | |
tree | 22889a0e787a22769cdc456780220cb23a412dd7 /Documentation/RelNotes/2.24.0.txt | |
parent | stash: make sure to write refreshed cache (diff) | |
download | tgif-df53c80822735ddd30638ba77be3face438d5ad8.tar.xz |
stash: make sure we have a valid index before writing it
In 'do_apply_stash()' we refresh the index in the end. Since
34933d0eff ("stash: make sure to write refreshed cache", 2019-09-11),
we also write that refreshed index when --quiet is given to 'git stash
apply'.
However if '--index' is not given to 'git stash apply', we also
discard the index in the else clause just before. We need to do so
because we use an external 'git update-index --add --stdin', which
leads to an out of date in-core index.
Later we call 'refresh_and_write_cache', which now leads to writing
the discarded index, which means we essentially write an empty index
file. This is obviously not correct, or the behaviour the user
wanted. We should not modify the users index without being asked to
do so.
Make sure to re-read the index after discarding the current in-core
index, to avoid dealing with outdated information. Instead we could
also drop the 'discard_cache()' + 'read_cache()', however that would
make it easy to fall into the same trap as 34933d0eff did, so it's
better to avoid that.
We can also drop the 'refresh_and_write_cache' completely in the quiet
case. Previously in legacy stash we relied on 'git status' to refresh
the index after calling 'git read-tree' when '--index' was passed to
'git apply'. However the 'reset_tree()' call that replaced 'git
read-tree' always passes options that are equivalent to '-m', making
the refresh of the index unnecessary.
Reported-by: Grzegorz Rajchman <rayman17@gmail.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/RelNotes/2.24.0.txt')
0 files changed, 0 insertions, 0 deletions