oidtree: avoid nested struct oidtree_node
[git/debian.git] / t / t4255-am-submodule.sh
bloba7ba08f728c0b870bf899ee82220a1708699dcb0
1 #!/bin/sh
3 test_description='git am handling submodules'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-submodule-update.sh
8 am () {
9 git format-patch --stdout --ignore-submodules=dirty "..$1" >patch &&
10 may_only_be_test_must_fail "$2" &&
11 $2 git am patch
14 test_submodule_switch_func "am"
16 am_3way () {
17 git format-patch --stdout --ignore-submodules=dirty "..$1" >patch &&
18 may_only_be_test_must_fail "$2" &&
19 $2 git am --3way patch
22 KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
23 test_submodule_switch_func "am_3way"
25 test_expect_success 'setup diff.submodule' '
26 test_commit one &&
27 INITIAL=$(git rev-parse HEAD) &&
29 git init submodule &&
31 cd submodule &&
32 test_commit two &&
33 git rev-parse HEAD >../initial-submodule
34 ) &&
35 git submodule add ./submodule &&
36 git commit -m first &&
39 cd submodule &&
40 test_commit three &&
41 git rev-parse HEAD >../first-submodule
42 ) &&
43 git add submodule &&
44 git commit -m second &&
45 SECOND=$(git rev-parse HEAD) &&
48 cd submodule &&
49 git mv two.t four.t &&
50 git commit -m "second submodule" &&
51 git rev-parse HEAD >../second-submodule
52 ) &&
53 test_commit four &&
54 git add submodule &&
55 git commit --amend --no-edit &&
56 THIRD=$(git rev-parse HEAD) &&
57 git submodule update --init
60 run_test() {
61 START_COMMIT=$1 &&
62 EXPECT=$2 &&
63 # Abort any merges in progress: the previous
64 # test may have failed, and we should clean up.
65 test_might_fail git am --abort &&
66 git reset --hard $START_COMMIT &&
67 rm -f *.patch &&
68 git format-patch -1 &&
69 git reset --hard $START_COMMIT^ &&
70 git submodule update &&
71 git am *.patch &&
72 git submodule update &&
73 git -C submodule rev-parse HEAD >actual &&
74 test_cmp $EXPECT actual
77 test_expect_success 'diff.submodule unset' '
78 test_unconfig diff.submodule &&
79 run_test $SECOND first-submodule
82 test_expect_success 'diff.submodule unset with extra file' '
83 test_unconfig diff.submodule &&
84 run_test $THIRD second-submodule
87 test_expect_success 'diff.submodule=log' '
88 test_config diff.submodule log &&
89 run_test $SECOND first-submodule
92 test_expect_success 'diff.submodule=log with extra file' '
93 test_config diff.submodule log &&
94 run_test $THIRD second-submodule
97 test_done