merge-octopus: abort if index does not match HEAD

Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Apr 9, 2016 at 23:13 UTC 3ec62ad9ffba2476e30fdf8e8717756fe62119f9
2 files changed +9 -3
git-merge-octopus.sh
+6
@@ -44,6 +44,12 @@ esac
44 # MRC is the current "merge reference commit"
45 # MRT is the current "merge result tree"
46
47 +if ! git diff-index --quiet --cached HEAD --
48 +then
49 + echo "Error: Your local changes to the following files would be overwritten by merge"
50 + git diff-index --cached --name-only HEAD -- | sed -e 's/^/ /'
51 + exit 2
52 +fi
53 MRC=$(git rev-parse --verify -q $head)
54 MRT=$(git write-tree)
55 NON_FF_MERGE=0
t/t6044-merge-unrelated-index-changes.sh
+3 -3
@@ -105,7 +105,7 @@ test_expect_success 'recursive' '
105 test_must_fail git merge -s recursive C^0
106 '
107
108 -test_expect_failure 'octopus, unrelated file touched' '
108 +test_expect_success 'octopus, unrelated file touched' '
109 git reset --hard &&
110 git checkout B^0 &&
111
@@ -114,7 +114,7 @@ test_expect_failure 'octopus, unrelated file touched' '
114 test_must_fail git merge C^0 D^0
115 '
116
117 -test_expect_failure 'octopus, related file removed' '
117 +test_expect_success 'octopus, related file removed' '
118 git reset --hard &&
119 git checkout B^0 &&
120
@@ -123,7 +123,7 @@ test_expect_failure 'octopus, related file removed' '
123 test_must_fail git merge C^0 D^0
124 '
125
126 -test_expect_failure 'octopus, related file modified' '
126 +test_expect_success 'octopus, related file modified' '
127 git reset --hard &&
128 git checkout B^0 &&
129