Skip to content

Commit 3ec62ad

Browse files
newrengitster
authored andcommitted
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>
1 parent a6ee883 commit 3ec62ad

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

git-merge-octopus.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ esac
4444
# MRC is the current "merge reference commit"
4545
# MRT is the current "merge result tree"
4646

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
4753
MRC=$(git rev-parse --verify -q $head)
4854
MRT=$(git write-tree)
4955
NON_FF_MERGE=0

t/t6044-merge-unrelated-index-changes.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ test_expect_success 'recursive' '
105105
test_must_fail git merge -s recursive C^0
106106
'
107107

108-
test_expect_failure 'octopus, unrelated file touched' '
108+
test_expect_success 'octopus, unrelated file touched' '
109109
git reset --hard &&
110110
git checkout B^0 &&
111111
@@ -114,7 +114,7 @@ test_expect_failure 'octopus, unrelated file touched' '
114114
test_must_fail git merge C^0 D^0
115115
'
116116

117-
test_expect_failure 'octopus, related file removed' '
117+
test_expect_success 'octopus, related file removed' '
118118
git reset --hard &&
119119
git checkout B^0 &&
120120
@@ -123,7 +123,7 @@ test_expect_failure 'octopus, related file removed' '
123123
test_must_fail git merge C^0 D^0
124124
'
125125

126-
test_expect_failure 'octopus, related file modified' '
126+
test_expect_success 'octopus, related file modified' '
127127
git reset --hard &&
128128
git checkout B^0 &&
129129

0 commit comments

Comments
 (0)