summaryrefslogtreecommitdiff
path: root/t/t4151-am-abort.sh
diff options
context:
space:
mode:
authorPaul Tan <pyokagan@gmail.com>2015-08-19 08:22:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-08-19 17:51:39 (GMT)
commit3ecc7040eff29fea0051df9faf21b0a73ee6d911 (patch)
treefbe6086d2dfcf89395832c6e957f182864e32060 /t/t4151-am-abort.sh
parente97a5e765db06995c3b027a5d7dceb6b4f2cba02 (diff)
downloadgit-3ecc7040eff29fea0051df9faf21b0a73ee6d911.zip
git-3ecc7040eff29fea0051df9faf21b0a73ee6d911.tar.gz
git-3ecc7040eff29fea0051df9faf21b0a73ee6d911.tar.bz2
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>
Diffstat (limited to 't/t4151-am-abort.sh')
-rwxr-xr-xt/t4151-am-abort.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh
index 05bdc3e..ea5ace9 100755
--- a/t/t4151-am-abort.sh
+++ b/t/t4151-am-abort.sh
@@ -168,4 +168,28 @@ test_expect_success 'am --abort on unborn branch will keep local commits intact'
test_cmp expect actual
'
+test_expect_success 'am --skip leaves index stat info alone' '
+ git checkout -f --orphan skip-stat-info &&
+ git reset &&
+ test_commit skip-should-be-untouched &&
+ test-chmtime =0 skip-should-be-untouched.t &&
+ git update-index --refresh &&
+ git diff-files --exit-code --quiet &&
+ test_must_fail git am 0001-*.patch &&
+ git am --skip &&
+ git diff-files --exit-code --quiet
+'
+
+test_expect_success 'am --abort leaves index stat info alone' '
+ git checkout -f --orphan abort-stat-info &&
+ git reset &&
+ test_commit abort-should-be-untouched &&
+ test-chmtime =0 abort-should-be-untouched.t &&
+ git update-index --refresh &&
+ git diff-files --exit-code --quiet &&
+ test_must_fail git am 0001-*.patch &&
+ git am --abort &&
+ git diff-files --exit-code --quiet
+'
+
test_done