(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"Merge base and parent list computation.\n">)} spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:M) op:Equal rhs:{(1130000000)} spids:[24])] spids: [24] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:Z) op:Equal rhs:{(Lit_Other "+") (0000)} spids:[27])] spids: [27] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GIT_COMMITTER_EMAIL) op: Equal rhs: {(git) (Lit_Other "@") (comm.iter.xz)} spids: [32] ) ] spids: [32] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GIT_COMMITTER_NAME) op: Equal rhs: {(SQ <"C O Mmiter">)} spids: [37] ) ] spids: [37] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GIT_AUTHOR_NAME) op: Equal rhs: {(SQ <"A U Thor">)} spids: [42] ) ] spids: [42] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GIT_AUTHOR_EMAIL) op: Equal rhs: {(git) (Lit_Other "@") (au.thor.xz)} spids: [47] ) ] spids: [47] ) (C {(export)} {(GIT_COMMITTER_EMAIL)} {(GIT_COMMITTER_NAME)} {(GIT_AUTHOR_NAME)} {(GIT_AUTHOR_EMAIL)}) (FuncDef name: doit body: (BraceGroup children: [ (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:OFFSET) op: Equal rhs: {($ VSub_Number "$1")} spids: [71] ) ] spids: [71] ) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:NAME) op: Equal rhs: {($ VSub_Number "$2")} spids: [77] ) ] spids: [77] ) (AndOr children: [ (C {(shift)} {(2)}) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PARENTS) op: Equal rhs: {(SQ )} spids: [91] ) ] spids: [91] ) (AndOr children: [ (ForEach iter_name: P do_arg_iter: True body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PARENTS) op: Equal rhs: { (DQ (${ VSub_Name PARENTS) ("-p ") ($ VSub_Name "$P") (" ") ) } spids: [104] ) ] spids: [104] ) ] spids: [101 115] ) spids: [-1 -1] ) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GIT_COMMITTER_DATE) op: Equal rhs: { (DQ (ArithSubPart anode: (ArithBinary op_id: Arith_Plus left: (ArithWord w:{($ VSub_Name "$M")}) right: (ArithWord w:{($ VSub_Name "$OFFSET")}) ) spids: [123 130] ) (" ") ($ VSub_Name "$Z") ) } spids: [121] ) ] spids: [121] ) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GIT_AUTHOR_DATE) op: Equal rhs: {($ VSub_Name "$GIT_COMMITTER_DATE")} spids: [138] ) ] spids: [138] ) (AndOr children: [ (C {(export)} {(GIT_COMMITTER_DATE)} {(GIT_AUTHOR_DATE)}) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:commit) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Name "$NAME")} ) (C {(git)} {(commit-tree)} {($ VSub_Name "$T")} {($ VSub_Name "$PARENTS")} ) ] negated: False ) ] ) left_token: <Left_CommandSub "$("> spids: [155 169] ) } spids: [154] ) ] spids: [154] ) (AndOr children: [ (SimpleCommand words: [{(echo)} {($ VSub_Name "$commit")}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(.git/refs/tags/) ($ VSub_Name "$NAME")} spids: [179] ) ] ) (C {(echo)} {($ VSub_Name "$commit")}) ] 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: [68] ) spids: [63 67] ) (C {(test_expect_success)} {(SQ <setup>)} {(SQ <"\n"> <"\tT=$(git mktree </dev/null)\n">)}) (C {(test_expect_success)} {(SQ <"set up G and H">)} { (SQ <"\n"> <"\t# E---D---C---B---A\n"> <"\t# \\\"-_ \\ \\\n"> <"\t# \\ `---------G \\\n"> <"\t# \\ \\\n"> <"\t# F----------------H\n"> <"\tE=$(doit 5 E) &&\n"> <"\tD=$(doit 4 D $E) &&\n"> <"\tF=$(doit 6 F $E) &&\n"> <"\tC=$(doit 3 C $D) &&\n"> <"\tB=$(doit 2 B $C) &&\n"> <"\tA=$(doit 1 A $B) &&\n"> <"\tG=$(doit 7 G $B $E) &&\n"> <"\tH=$(doit 8 H $A $F)\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-base G H">)} { (SQ <"\n"> <"\tgit name-rev $B >expected &&\n"> <"\n"> <"\tMB=$(git merge-base G H) &&\n"> <"\tgit name-rev \"$MB\" >actual.single &&\n"> <"\n"> <"\tMB=$(git merge-base --all G H) &&\n"> <"\tgit name-rev \"$MB\" >actual.all &&\n"> <"\n"> <"\tMB=$(git show-branch --merge-base G H) &&\n"> <"\tgit name-rev \"$MB\" >actual.sb &&\n"> <"\n"> <"\ttest_cmp expected actual.single &&\n"> <"\ttest_cmp expected actual.all &&\n"> <"\ttest_cmp expected actual.sb\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-base/show-branch --independent">)} { (SQ <"\n"> <"\tgit name-rev \"$H\" >expected1 &&\n"> <"\tgit name-rev \"$H\" \"$G\" >expected2 &&\n"> <"\n"> <"\tparents=$(git merge-base --independent H) &&\n"> <"\tgit name-rev $parents >actual1.mb &&\n"> <"\tparents=$(git merge-base --independent A H G) &&\n"> <"\tgit name-rev $parents >actual2.mb &&\n"> <"\n"> <"\tparents=$(git show-branch --independent H) &&\n"> <"\tgit name-rev $parents >actual1.sb &&\n"> <"\tparents=$(git show-branch --independent A H G) &&\n"> <"\tgit name-rev $parents >actual2.sb &&\n"> <"\n"> <"\ttest_cmp expected1 actual1.mb &&\n"> <"\ttest_cmp expected2 actual2.mb &&\n"> <"\ttest_cmp expected1 actual1.sb &&\n"> <"\ttest_cmp expected2 actual2.sb\n"> ) } ) (C {(test_expect_success)} {(SQ <"unsynchronized clocks">)} { (SQ <"\n"> <"\t# This test is to demonstrate that relying on timestamps in a distributed\n"> <"\t# SCM to provide a _consistent_ partial ordering of commits leads to\n"> <"\t# insanity.\n"> <"\t#\n"> <"\t# Relative\n"> <"\t# Structure timestamps\n"> <"\t#\n"> <"\t# PL PR +4 +4\n"> <"\t# / \\/ \\ / \\/ \\\n"> <"\t# L2 C2 R2 +3 -1 +3\n"> <"\t# | | | | | |\n"> <"\t# L1 C1 R1 +2 -2 +2\n"> <"\t# | | | | | |\n"> <"\t# L0 C0 R0 +1 -3 +1\n"> <"\t# \\ | / \\ | /\n"> <"\t# S 0\n"> <"\t#\n"> <"\t# The left and right chains of commits can be of any length and complexity as\n"> <"\t# long as all of the timestamps are greater than that of S.\n"> <"\n"> <"\tS=$(doit 0 S) &&\n"> <"\n"> <"\tC0=$(doit -3 C0 $S) &&\n"> <"\tC1=$(doit -2 C1 $C0) &&\n"> <"\tC2=$(doit -1 C2 $C1) &&\n"> <"\n"> <"\tL0=$(doit 1 L0 $S) &&\n"> <"\tL1=$(doit 2 L1 $L0) &&\n"> <"\tL2=$(doit 3 L2 $L1) &&\n"> <"\n"> <"\tR0=$(doit 1 R0 $S) &&\n"> <"\tR1=$(doit 2 R1 $R0) &&\n"> <"\tR2=$(doit 3 R2 $R1) &&\n"> <"\n"> <"\tPL=$(doit 4 PL $L2 $C2) &&\n"> <"\tPR=$(doit 4 PR $C2 $R2) &&\n"> <"\n"> <"\tgit name-rev $C2 >expected &&\n"> <"\n"> <"\tMB=$(git merge-base PL PR) &&\n"> <"\tgit name-rev \"$MB\" >actual.single &&\n"> <"\n"> <"\tMB=$(git merge-base --all PL PR) &&\n"> <"\tgit name-rev \"$MB\" >actual.all &&\n"> <"\n"> <"\ttest_cmp expected actual.single &&\n"> <"\ttest_cmp expected actual.all\n"> ) } ) (C {(test_expect_success)} {(SQ <"--independent with unsynchronized clocks">)} { (SQ <"\n"> <"\tIB=$(doit 0 IB) &&\n"> <"\tI1=$(doit -10 I1 $IB) &&\n"> <"\tI2=$(doit -9 I2 $I1) &&\n"> <"\tI3=$(doit -8 I3 $I2) &&\n"> <"\tI4=$(doit -7 I4 $I3) &&\n"> <"\tI5=$(doit -6 I5 $I4) &&\n"> <"\tI6=$(doit -5 I6 $I5) &&\n"> <"\tI7=$(doit -4 I7 $I6) &&\n"> <"\tI8=$(doit -3 I8 $I7) &&\n"> <"\tIH=$(doit -2 IH $I8) &&\n"> <"\n"> <"\techo $IH >expected &&\n"> <"\tgit merge-base --independent IB IH >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-base for octopus-step (setup)">)} { (SQ <"\n"> <"\t# Another set to demonstrate base between one commit and a merge\n"> <"\t# in the documentation.\n"> <"\t#\n"> <"\t# * C (MMC) * B (MMB) * A (MMA)\n"> <"\t# * o * o * o\n"> <"\t# * o * o * o\n"> <"\t# * o * o * o\n"> <"\t# * o | _______/\n"> <"\t# | |/\n"> <"\t# | * 1 (MM1)\n"> <"\t# | _______/\n"> <"\t# |/\n"> <"\t# * root (MMR)\n"> <"\n"> <"\ttest_commit MMR &&\n"> <"\ttest_commit MM1 &&\n"> <"\ttest_commit MM-o &&\n"> <"\ttest_commit MM-p &&\n"> <"\ttest_commit MM-q &&\n"> <"\ttest_commit MMA &&\n"> <"\tgit checkout MM1 &&\n"> <"\ttest_commit MM-r &&\n"> <"\ttest_commit MM-s &&\n"> <"\ttest_commit MM-t &&\n"> <"\ttest_commit MMB &&\n"> <"\tgit checkout MMR &&\n"> <"\ttest_commit MM-u &&\n"> <"\ttest_commit MM-v &&\n"> <"\ttest_commit MM-w &&\n"> <"\ttest_commit MM-x &&\n"> <"\ttest_commit MMC\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-base A B C">)} { (SQ <"\n"> <"\tgit rev-parse --verify MM1 >expected &&\n"> <"\tgit rev-parse --verify MMR >expected.sb &&\n"> <"\n"> <"\tgit merge-base --all MMA MMB MMC >actual &&\n"> <"\tgit merge-base --all --octopus MMA MMB MMC >actual.common &&\n"> <"\tgit show-branch --merge-base MMA MMB MMC >actual.sb &&\n"> <"\n"> <"\ttest_cmp expected actual &&\n"> <"\ttest_cmp expected.sb actual.common &&\n"> <"\ttest_cmp expected.sb actual.sb\n"> ) } ) (C {(test_expect_success)} {(SQ <"criss-cross merge-base for octopus-step">)} { (SQ <"\n"> <"\tgit reset --hard MMR &&\n"> <"\ttest_commit CC1 &&\n"> <"\tgit reset --hard E &&\n"> <"\ttest_commit CC2 &&\n"> <"\ttest_tick &&\n"> <"\t# E is a root commit unrelated to MMR root on which CC1 is based\n"> <"\tgit merge -s ours --allow-unrelated-histories CC1 &&\n"> <"\ttest_commit CC-o &&\n"> <"\ttest_commit CCB &&\n"> <"\tgit reset --hard CC1 &&\n"> <"\t# E is a root commit unrelated to MMR root on which CC1 is based\n"> <"\tgit merge -s ours --allow-unrelated-histories CC2 &&\n"> <"\ttest_commit CCA &&\n"> <"\n"> <"\tgit rev-parse CC1 CC2 >expected &&\n"> <"\tgit merge-base --all CCB CCA^^ CCA^^2 >actual &&\n"> <"\n"> <"\tsort expected >expected.sorted &&\n"> <"\tsort actual >actual.sorted &&\n"> <"\ttest_cmp expected.sorted actual.sorted\n"> ) } ) (C {(test_expect_success)} {(SQ <"using reflog to find the fork point">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout -b base $E &&\n"> <"\n"> <"\t(\n"> <"\t\tfor count in 1 2 3\n"> <"\t\tdo\n"> <"\t\t\tgit commit --allow-empty -m \"Base commit #$count\" &&\n"> <"\t\t\tgit rev-parse HEAD >expect$count &&\n"> <"\t\t\tgit checkout -B derived &&\n"> <"\t\t\tgit commit --allow-empty -m \"Derived #$count\" &&\n"> <"\t\t\tgit rev-parse HEAD >derived$count &&\n"> <"\t\t\tgit checkout -B base $E || exit 1\n"> <"\t\tdone\n"> <"\n"> <"\t\tfor count in 1 2 3\n"> <"\t\tdo\n"> <"\t\t\tgit merge-base --fork-point base $(cat derived$count) >actual &&\n"> <"\t\t\ttest_cmp expect$count actual || exit 1\n"> <"\t\tdone\n"> <"\n"> <"\t) &&\n"> <"\t# check that we correctly default to HEAD\n"> <"\tgit checkout derived &&\n"> <"\tgit merge-base --fork-point base >actual &&\n"> <"\ttest_cmp expect3 actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"--fork-point works with empty reflog">)} { (SQ <"\n"> <"\tgit -c core.logallrefupdates=false branch no-reflog base &&\n"> <"\tgit merge-base --fork-point no-reflog derived &&\n"> <"\ttest_cmp expect3 actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-base --octopus --all for complex tree">)} { (SQ <"\n"> <"\t# Best common ancestor for JE, JAA and JDD is JC\n"> <"\t# JE\n"> <"\t# / |\n"> <"\t# / |\n"> <"\t# / |\n"> <"\t# JAA / |\n"> <"\t# |\\ / |\n"> <"\t# | \\ | JDD |\n"> <"\t# | \\ |/ | |\n"> <"\t# | JC JD |\n"> <"\t# | | /| |\n"> <"\t# | |/ | |\n"> <"\t# JA | | |\n"> <"\t# |\\ /| | |\n"> <"\t# X JB | X X\n"> <"\t# \\ \\ | / /\n"> <"\t# \\__\\|/___/\n"> <"\t# J\n"> <"\ttest_commit J &&\n"> <"\ttest_commit JB &&\n"> <"\tgit reset --hard J &&\n"> <"\ttest_commit JC &&\n"> <"\tgit reset --hard J &&\n"> <"\ttest_commit JTEMP1 &&\n"> <"\ttest_merge JA JB &&\n"> <"\ttest_merge JAA JC &&\n"> <"\tgit reset --hard J &&\n"> <"\ttest_commit JTEMP2 &&\n"> <"\ttest_merge JD JB &&\n"> <"\ttest_merge JDD JC &&\n"> <"\tgit reset --hard J &&\n"> <"\ttest_commit JTEMP3 &&\n"> <"\ttest_merge JE JC &&\n"> <"\tgit rev-parse JC >expected &&\n"> <"\tgit merge-base --all --octopus JAA JDD JE >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_done)}) ] )