am --skip/--abort: merge HEAD/ORIG_HEAD tree into index
commit3ecc7040eff29fea0051df9faf21b0a73ee6d911
authorPaul Tan <pyokagan@gmail.com>
Wed, 19 Aug 2015 08:22:22 +0000 (19 16:22 +0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 Aug 2015 17:51:39 +0000 (19 10:51 -0700)
treefbe6086d2dfcf89395832c6e957f182864e32060
parente97a5e765db06995c3b027a5d7dceb6b4f2cba02
am --skip/--abort: merge HEAD/ORIG_HEAD tree into index

After running "git am --abort", and then running "git reset --hard",
files that were not modified would still be re-checked out.

This is because clean_index() in builtin/am.c mistakenly called the
read_tree() function, which overwrites all entries in the index,
including the stat info.

"git am --skip" did not seem to have this issue because am_skip() called
am_run(), which called refresh_cache() to update the stat info. However,
there's still a performance penalty as the lack of stat info meant that
refresh_cache() would have to scan all files for changes.

Fix this by using unpack_trees() instead to merge the tree into the
index, so that the stat info from the index is kept.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Paul Tan <pyokagan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/am.c
t/t4151-am-abort.sh