merge: add t7613 for submodule updates

Test that the merge command updates the work tree as expected (for submodule changes which don't result in conflicts) when used without arguments or with the '--ff', '--ff-only' and '--no-ff' flag. Implement the KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR switch to expect the known failure that --no-ff merges do not create the empty submodule directory. The KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES switch is also implemented to expect the known failure that --no-ff merges attempt to merge the new files in the former submodule directory with those of the removed submodule. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jens Lehmann committed Jun 15, 2014 at 19:01 UTC 663ed39a889dae8beee2fc6953607f7660a5cddf
2 files changed +40 -3
t/lib-submodule-update.sh
+21 -3
@@ -285,7 +285,16 @@ test_submodule_switch () {
285 '
286 # ... as does removing a directory with tracked files with a
287 # submodule.
288 - test_expect_success "$command: replace directory with submodule" '
288 + if test "$KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR" = 1
289 + then
290 + # Non fast-forward merges fail with "Directory sub1 doesn't
291 + # exist. sub1" because the empty submodule directory is not
292 + # created
293 + RESULT="failure"
294 + else
295 + RESULT="success"
296 + fi
297 + test_expect_$RESULT "$command: replace directory with submodule" '
298 prolog &&
299 reset_work_tree_to replace_sub1_with_directory &&
300 (
@@ -328,7 +337,16 @@ test_submodule_switch () {
337 '
338 # Replacing a submodule with files in a directory must fail as the
339 # submodule work tree isn't removed ...
331 - test_expect_success "$command: replace submodule with a directory must fail" '
340 + if test "$KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES" = 1
341 + then
342 + # Non fast-forward merges attempt to merge the former
343 + # submodule files with the newly checked out ones in the
344 + # directory of the same name while it shouldn't.
345 + RESULT="failure"
346 + else
347 + RESULT="success"
348 + fi
349 + test_expect_$RESULT "$command: replace submodule with a directory must fail" '
350 prolog &&
351 reset_work_tree_to add_sub1 &&
352 (
@@ -340,7 +358,7 @@ test_submodule_switch () {
358 )
359 '
360 # ... especially when it contains a .git directory.
343 - test_expect_success "$command: replace submodule containing a .git directory with a directory must fail" '
361 + test_expect_$RESULT "$command: replace submodule containing a .git directory with a directory must fail" '
362 prolog &&
363 reset_work_tree_to add_sub1 &&
364 (
t/t7613-merge-submodule.sh new
+19
@@ -0,0 +1,19 @@
1 +#!/bin/sh
2 +
3 +test_description='merge can handle submodules'
4 +
5 +. ./test-lib.sh
6 +. "$TEST_DIRECTORY"/lib-submodule-update.sh
7 +
8 +# merges without conflicts
9 +test_submodule_switch "git merge"
10 +
11 +test_submodule_switch "git merge --ff"
12 +
13 +test_submodule_switch "git merge --ff-only"
14 +
15 +KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
16 +KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
17 +test_submodule_switch "git merge --no-ff"
18 +
19 +test_done