]>
Commit | Line | Data |
---|---|---|
23e2f388 JL |
1 | #!/bin/sh |
2 | ||
3 | test_description='git am handling submodules' | |
4 | ||
14da2623 | 5 | TEST_PASSES_SANITIZE_LEAK=true |
23e2f388 JL |
6 | . ./test-lib.sh |
7 | . "$TEST_DIRECTORY"/lib-submodule-update.sh | |
8 | ||
9 | am () { | |
5b0ac09f DL |
10 | git format-patch --stdout --ignore-submodules=dirty "..$1" >patch && |
11 | may_only_be_test_must_fail "$2" && | |
12 | $2 git am patch | |
23e2f388 JL |
13 | } |
14 | ||
aa06180a | 15 | test_submodule_switch_func "am" |
23e2f388 JL |
16 | |
17 | am_3way () { | |
5b0ac09f DL |
18 | git format-patch --stdout --ignore-submodules=dirty "..$1" >patch && |
19 | may_only_be_test_must_fail "$2" && | |
20 | $2 git am --3way patch | |
23e2f388 JL |
21 | } |
22 | ||
23 | KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1 | |
aa06180a | 24 | test_submodule_switch_func "am_3way" |
23e2f388 | 25 | |
fe7611c4 DK |
26 | test_expect_success 'setup diff.submodule' ' |
27 | test_commit one && | |
28 | INITIAL=$(git rev-parse HEAD) && | |
29 | ||
30 | git init submodule && | |
31 | ( | |
32 | cd submodule && | |
33 | test_commit two && | |
34 | git rev-parse HEAD >../initial-submodule | |
35 | ) && | |
36 | git submodule add ./submodule && | |
37 | git commit -m first && | |
38 | ||
39 | ( | |
40 | cd submodule && | |
41 | test_commit three && | |
42 | git rev-parse HEAD >../first-submodule | |
43 | ) && | |
44 | git add submodule && | |
45 | git commit -m second && | |
46 | SECOND=$(git rev-parse HEAD) && | |
47 | ||
48 | ( | |
49 | cd submodule && | |
50 | git mv two.t four.t && | |
51 | git commit -m "second submodule" && | |
52 | git rev-parse HEAD >../second-submodule | |
53 | ) && | |
54 | test_commit four && | |
55 | git add submodule && | |
56 | git commit --amend --no-edit && | |
57 | THIRD=$(git rev-parse HEAD) && | |
58 | git submodule update --init | |
59 | ' | |
60 | ||
61 | run_test() { | |
62 | START_COMMIT=$1 && | |
63 | EXPECT=$2 && | |
64 | # Abort any merges in progress: the previous | |
65 | # test may have failed, and we should clean up. | |
66 | test_might_fail git am --abort && | |
67 | git reset --hard $START_COMMIT && | |
68 | rm -f *.patch && | |
69 | git format-patch -1 && | |
70 | git reset --hard $START_COMMIT^ && | |
71 | git submodule update && | |
72 | git am *.patch && | |
73 | git submodule update && | |
74 | git -C submodule rev-parse HEAD >actual && | |
75 | test_cmp $EXPECT actual | |
76 | } | |
77 | ||
78 | test_expect_success 'diff.submodule unset' ' | |
79 | test_unconfig diff.submodule && | |
80 | run_test $SECOND first-submodule | |
81 | ' | |
82 | ||
83 | test_expect_success 'diff.submodule unset with extra file' ' | |
84 | test_unconfig diff.submodule && | |
85 | run_test $THIRD second-submodule | |
86 | ' | |
87 | ||
339de508 | 88 | test_expect_success 'diff.submodule=log' ' |
fe7611c4 DK |
89 | test_config diff.submodule log && |
90 | run_test $SECOND first-submodule | |
91 | ' | |
92 | ||
339de508 | 93 | test_expect_success 'diff.submodule=log with extra file' ' |
fe7611c4 DK |
94 | test_config diff.submodule log && |
95 | run_test $THIRD second-submodule | |
96 | ' | |
97 | ||
23e2f388 | 98 | test_done |