Skip to content

Commit cf69f2a

Browse files
newrengitster
authored andcommitted
t6044: add a testcase for index matching head, when head doesn't match HEAD
The `git merge-recursive` command allows the user to directly specify three commits to merge -- base, head, and remote. (More than three can be specified in the case of multiple merge bases.) Note that since the user is allowed to specify head, it need not match HEAD. Virtually every test and script in the current git.git codebase calls `git merge-recursive` with head=HEAD, and likely external callers do as well, which is why this has gone unnoticed. There is one notable counter-example: git-stash.sh. However, git-stash called `git merge-recursive` with an index that matches the expected merge result, which happens to be a currently allowed exception to the "index must match head" rule, so this never triggered an error previously. Since we would like to tighten up the "index must match head" rule, we need to make sure we are comparing to the correct head. Add a testcase that demonstrates the failure when we check the wrong HEAD. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 58f4d1b commit cf69f2a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ test_expect_failure 'recursive, when merge branch matches merge base' '
126126
test_path_is_missing .git/MERGE_HEAD
127127
'
128128

129+
test_expect_failure 'merge-recursive, when index==head but head!=HEAD' '
130+
git reset --hard &&
131+
git checkout C^0 &&
132+
133+
# Make index match B
134+
git diff C B -- | git apply --cached &&
135+
# Merge B & F, with B as "head"
136+
git merge-recursive A -- B F > out &&
137+
test_i18ngrep "Already up to date" out
138+
'
139+
129140
test_expect_success 'octopus, unrelated file touched' '
130141
git reset --hard &&
131142
git checkout B^0 &&

0 commit comments

Comments
 (0)