#!/bin/sh global test_description := ''git am handling submodules'' source ./test-lib.sh source "$TEST_DIRECTORY"/lib-submodule-update.sh proc am { git format-patch --stdout --ignore-submodules=dirty "..$1" | git am - } test_submodule_switch "am" proc am_3way { git format-patch --stdout --ignore-submodules=dirty "..$1" | git am --3way - } global KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES := '1' test_submodule_switch "am_3way" test_expect_success 'setup diff.submodule' ' test_commit one && INITIAL=$(git rev-parse HEAD) && git init submodule && ( cd submodule && test_commit two && git rev-parse HEAD >../initial-submodule ) && git submodule add ./submodule && git commit -m first && ( cd submodule && test_commit three && git rev-parse HEAD >../first-submodule ) && git add submodule && git commit -m second && SECOND=$(git rev-parse HEAD) && ( cd submodule && git mv two.t four.t && git commit -m "second submodule" && git rev-parse HEAD >../second-submodule ) && test_commit four && git add submodule && git commit --amend --no-edit && THIRD=$(git rev-parse HEAD) && git submodule update --init ' proc run_test { global START_COMMIT := $1 && global EXPECT := $2 && # Abort any merges in progress: the previous # test may have failed, and we should clean up. test_might_fail git am --abort && git reset --hard $START_COMMIT && rm -f *.patch && git format-patch -1 && git reset --hard $START_COMMIT^ && git submodule update && git am *.patch && git submodule update && git -C submodule rev-parse HEAD >actual && test_cmp $EXPECT actual } test_expect_success 'diff.submodule unset' ' test_unconfig diff.submodule && run_test $SECOND first-submodule ' test_expect_success 'diff.submodule unset with extra file' ' test_unconfig diff.submodule && run_test $THIRD second-submodule ' test_expect_success 'diff.submodule=log' ' test_config diff.submodule log && run_test $SECOND first-submodule ' test_expect_success 'diff.submodule=log with extra file' ' test_config diff.submodule log && run_test $THIRD second-submodule ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git am handling submodules">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-submodule-update.sh)}) (FuncDef name: am body: (BraceGroup children: [ (Pipeline children: [ (C {(git)} {(format-patch)} {(--stdout)} {(--ignore-submodules) (Lit_Other "=") (dirty)} {(DQ (..) ($ VSub_Number "$1"))} ) (C {(git)} {(am)} {(-)}) ] negated: False ) ] spids: [27] ) spids: [22 26] ) (C {(test_submodule_switch)} {(DQ (am))}) (FuncDef name: am_3way body: (BraceGroup children: [ (Pipeline children: [ (C {(git)} {(format-patch)} {(--stdout)} {(--ignore-submodules) (Lit_Other "=") (dirty)} {(DQ (..) ($ VSub_Number "$1"))} ) (C {(git)} {(am)} {(--3way)} {(-)}) ] negated: False ) ] spids: [68] ) spids: [63 67] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES) op: Equal rhs: {(1)} spids: [99] ) ] spids: [99] ) (C {(test_submodule_switch)} {(DQ (am_3way))}) (C {(test_expect_success)} {(SQ <"setup diff.submodule">)} { (SQ <"\n"> <"\ttest_commit one &&\n"> <"\tINITIAL=$(git rev-parse HEAD) &&\n"> <"\n"> <"\tgit init submodule &&\n"> <"\t(\n"> <"\t\tcd submodule &&\n"> <"\t\ttest_commit two &&\n"> <"\t\tgit rev-parse HEAD >../initial-submodule\n"> <"\t) &&\n"> <"\tgit submodule add ./submodule &&\n"> <"\tgit commit -m first &&\n"> <"\n"> <"\t(\n"> <"\t\tcd submodule &&\n"> <"\t\ttest_commit three &&\n"> <"\t\tgit rev-parse HEAD >../first-submodule\n"> <"\t) &&\n"> <"\tgit add submodule &&\n"> <"\tgit commit -m second &&\n"> <"\tSECOND=$(git rev-parse HEAD) &&\n"> <"\n"> <"\t(\n"> <"\t\tcd submodule &&\n"> <"\t\tgit mv two.t four.t &&\n"> <"\t\tgit commit -m \"second submodule\" &&\n"> <"\t\tgit rev-parse HEAD >../second-submodule\n"> <"\t) &&\n"> <"\ttest_commit four &&\n"> <"\tgit add submodule &&\n"> <"\tgit commit --amend --no-edit &&\n"> <"\tTHIRD=$(git rev-parse HEAD) &&\n"> <"\tgit submodule update --init\n"> ) } ) (FuncDef name: run_test body: (BraceGroup children: [ (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:START_COMMIT) op: Equal rhs: {($ VSub_Number "$1")} spids: [159] ) ] spids: [159] ) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:EXPECT) op: Equal rhs: {($ VSub_Number "$2")} spids: [165] ) ] spids: [165] ) (AndOr children: [ (C {(test_might_fail)} {(git)} {(am)} {(--abort)}) (AndOr children: [ (C {(git)} {(reset)} {(--hard)} {($ VSub_Name "$START_COMMIT")}) (AndOr children: [ (C {(rm)} {(-f)} {(Lit_Other "*") (.patch)}) (AndOr children: [ (C {(git)} {(format-patch)} {(-1)}) (AndOr children: [ (C {(git)} {(reset)} {(--hard)} {($ VSub_Name "$START_COMMIT") (Lit_Other "^")} ) (AndOr children: [ (C {(git)} {(submodule)} {(update)}) (AndOr children: [ (C {(git)} {(am)} {(Lit_Other "*") (.patch)}) (AndOr children: [ (C {(git)} {(submodule)} {(update)}) (AndOr children: [ (SimpleCommand words: [ {(git)} {(-C)} {(submodule)} {(rev-parse)} {(HEAD)} ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(actual)} spids: [270] ) ] ) (C {(test_cmp)} {($ VSub_Name "$EXPECT")} {(actual)} ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [156] ) spids: [152 155] ) (C {(test_expect_success)} {(SQ <"diff.submodule unset">)} {(SQ <"\n"> <"\ttest_unconfig diff.submodule &&\n"> <"\trun_test $SECOND first-submodule\n">)} ) (C {(test_expect_success)} {(SQ <"diff.submodule unset with extra file">)} {(SQ <"\n"> <"\ttest_unconfig diff.submodule &&\n"> <"\trun_test $THIRD second-submodule\n">)} ) (C {(test_expect_success)} {(SQ <"diff.submodule=log">)} { (SQ <"\n"> <"\ttest_config diff.submodule log &&\n"> <"\trun_test $SECOND first-submodule\n">) } ) (C {(test_expect_success)} {(SQ <"diff.submodule=log with extra file">)} { (SQ <"\n"> <"\ttest_config diff.submodule log &&\n"> <"\trun_test $THIRD second-submodule\n">) } ) (C {(test_done)}) ] )