aboutsummaryrefslogtreecommitdiff
path: root/t/t7607-merge-overwrite.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2011-03-25 14:10:38 -0400
committerJunio C Hamano <gitster@pobox.com>2011-03-25 14:16:01 -0700
commit97b1b4f3a682377aa8f03348618e79bd1df1772e (patch)
treeba48b388b69bc7bb7d86bcf46bba42d28baf51b0 /t/t7607-merge-overwrite.sh
parentd6d9e76d7f06c5ba94517d258e051544885780c5 (diff)
downloadgit-97b1b4f3a682377aa8f03348618e79bd1df1772e.tar.gz
git-97b1b4f3a682377aa8f03348618e79bd1df1772e.tar.xz
merge: merge unborn index before setting ref
When we merge into an unborn branch, there are basically two steps: 1. Write the sha1 of the new commit into the ref pointed to by HEAD. 2. Update the index with the new content, and check it out to the working tree. We currently do them in this order. However, (2) is the step that is much more likely to fail, since it can be blocked by things like untracked working tree files. When it does, the merge fails and we are left with an empty index but an updated HEAD. This patch switches the order, so that a failure in updating the index leaves us unchanged. Of course, a failure in updating the ref now leaves us with an updated index and mis-matched HEAD. That is arguably not much better, but it is probably less likely to actually happen. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7607-merge-overwrite.sh')
-rwxr-xr-xt/t7607-merge-overwrite.sh4
1 files changed, 4 insertions, 0 deletions
diff --git a/t/t7607-merge-overwrite.sh b/t/t7607-merge-overwrite.sh
index c86e298d0..b54e840ee 100755
--- a/t/t7607-merge-overwrite.sh
+++ b/t/t7607-merge-overwrite.sh
@@ -157,6 +157,10 @@ test_expect_success 'will not overwrite untracked file on unborn branch' '
test_cmp important c0.c
'
+test_expect_success 'failed merge leaves unborn branch in the womb' '
+ test_must_fail git rev-parse --verify HEAD
+'
+
test_expect_success 'set up unborn branch and content' '
git symbolic-ref HEAD refs/heads/unborn &&
rm -f .git/index &&