#!/bin/sh global test_description := ''Revision traversal vs grafts and path limiter'' source ./test-lib.sh test_expect_success setup ' mkdir subdir && echo >fileA fileA && echo >subdir/fileB fileB && git add fileA subdir/fileB && git commit -a -m "Initial in one history." && A0=$(git rev-parse --verify HEAD) && echo >fileA fileA modified && git commit -a -m "Second in one history." && A1=$(git rev-parse --verify HEAD) && echo >subdir/fileB fileB modified && git commit -a -m "Third in one history." && A2=$(git rev-parse --verify HEAD) && rm -f .git/refs/heads/master .git/index && echo >fileA fileA again && echo >subdir/fileB fileB again && git add fileA subdir/fileB && git commit -a -m "Initial in alternate history." && B0=$(git rev-parse --verify HEAD) && echo >fileA fileA modified in alternate history && git commit -a -m "Second in alternate history." && B1=$(git rev-parse --verify HEAD) && echo >subdir/fileB fileB modified in alternate history && git commit -a -m "Third in alternate history." && B2=$(git rev-parse --verify HEAD) && : done ' proc check { global type := $1 shift global arg := '' global which := 'arg' rm -f test.expectfor a in @Argv { if test "z$a" = z-- { global which := 'expect' global child := '' continue } if test $which = arg { global arg := ""$arg$a "" continue } if test $type = basic { echo $a } else { if test "z$child" != z { echo "$child $a" } global child := $a } } >test.expect if test $type != basic && test "z$child" != z { echo >>test.expect $child>>test.expect $child } if test $type = basic { git rev-list $arg >test.actual } elif test $type = parents { git rev-list --parents $arg >test.actual } elif test $type = parents-raw { git rev-list --parents --pretty=raw $arg | sed -n -e 's/^commit //p' >test.actual } test_cmp test.expect test.actual } for type in [basic parents parents-raw] { test_expect_success 'without grafts' " rm -f .git/info/grafts && check $type $B2 -- $B2 $B1 $B0 " test_expect_success 'with grafts' " echo '$B0 $A2' >.git/info/grafts && check $type $B2 -- $B2 $B1 $B0 $A2 $A1 $A0 " test_expect_success 'without grafts, with pathlimit' " rm -f .git/info/grafts && check $type $B2 subdir -- $B2 $B0 " test_expect_success 'with grafts, with pathlimit' " echo '$B0 $A2' >.git/info/grafts && check $type $B2 subdir -- $B2 $B0 $A2 $A0 " } test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"Revision traversal vs grafts and path limiter">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\tmkdir subdir &&\n"> <"\techo >fileA fileA &&\n"> <"\techo >subdir/fileB fileB &&\n"> <"\tgit add fileA subdir/fileB &&\n"> <"\tgit commit -a -m \"Initial in one history.\" &&\n"> <"\tA0=$(git rev-parse --verify HEAD) &&\n"> <"\n"> <"\techo >fileA fileA modified &&\n"> <"\tgit commit -a -m \"Second in one history.\" &&\n"> <"\tA1=$(git rev-parse --verify HEAD) &&\n"> <"\n"> <"\techo >subdir/fileB fileB modified &&\n"> <"\tgit commit -a -m \"Third in one history.\" &&\n"> <"\tA2=$(git rev-parse --verify HEAD) &&\n"> <"\n"> <"\trm -f .git/refs/heads/master .git/index &&\n"> <"\n"> <"\techo >fileA fileA again &&\n"> <"\techo >subdir/fileB fileB again &&\n"> <"\tgit add fileA subdir/fileB &&\n"> <"\tgit commit -a -m \"Initial in alternate history.\" &&\n"> <"\tB0=$(git rev-parse --verify HEAD) &&\n"> <"\n"> <"\techo >fileA fileA modified in alternate history &&\n"> <"\tgit commit -a -m \"Second in alternate history.\" &&\n"> <"\tB1=$(git rev-parse --verify HEAD) &&\n"> <"\n"> <"\techo >subdir/fileB fileB modified in alternate history &&\n"> <"\tgit commit -a -m \"Third in alternate history.\" &&\n"> <"\tB2=$(git rev-parse --verify HEAD) &&\n"> <"\t: done\n"> ) } ) (FuncDef name: check body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:type) op: Equal rhs: {($ VSub_Number "$1")} spids: [63] ) ] spids: [63] ) (C {(shift)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:arg) op:Equal rhs:{(SQ )} spids:[71])] spids: [71] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:which) op:Equal rhs:{(arg)} spids:[74])] spids: [74] ) (C {(rm)} {(-f)} {(test.expect)}) (ForEach iter_name: a do_arg_iter: True body: (DoGroup children: [ (If arms: [ (if_arm cond: [(C {(test)} {(DQ (z) ($ VSub_Name "$a"))} {(Lit_Other "=")} {(z--)})] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:which) op: Equal rhs: {(expect)} spids: [110] ) ] spids: [110] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:child) op: Equal rhs: {(SQ )} spids: [114] ) ] spids: [114] ) (ControlFlow token: ) ] spids: [-1 107] ) ] spids: [-1 120] ) (If arms: [ (if_arm cond: [(C {(test)} {(DQ ($ VSub_Name "$which"))} {(Lit_Other "=")} {(arg)})] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:arg) op: Equal rhs: {(DQ ($ VSub_Name "$arg") ($ VSub_Name "$a") (" "))} spids: [139] ) ] spids: [139] ) (ControlFlow token: ) ] spids: [-1 136] ) ] spids: [-1 150] ) (If arms: [ (if_arm cond: [(C {(test)} {(DQ ($ VSub_Name "$type"))} {(Lit_Other "=")} {(basic)})] action: [(C {(echo)} {(DQ ($ VSub_Name "$a"))})] spids: [-1 166] ) ] else_action: [ (If arms: [ (if_arm cond: [ (C {(test)} {(DQ (z) ($ VSub_Name "$child"))} {(KW_Bang "!") (Lit_Other "=")} {(z)} ) ] action: [ (C {(echo)} {(DQ ($ VSub_Name "$child") (" ") ($ VSub_Name "$a"))}) ] spids: [-1 194] ) ] spids: [-1 206] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:child) op: Equal rhs: {(DQ ($ VSub_Name "$a"))} spids: [209] ) ] spids: [209] ) ] spids: [176 215] ) ] spids: [90 218] ) redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(test.expect)} spids:[220])] spids: [-1 -1] ) (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(test)} {(DQ ($ VSub_Name "$type"))} {(KW_Bang "!") (Lit_Other "=")} {(basic)} ) (C {(test)} {(DQ (z) ($ VSub_Name "$child"))} {(KW_Bang "!") (Lit_Other "=")} {(z)} ) ] op_id: Op_DAmp ) ] action: [ (SimpleCommand words: [{(echo)} {($ VSub_Name "$child")}] redirects: [ (Redir op_id: Redir_DGreat fd: -1 arg_word: {(test.expect)} spids: [257] ) ] ) ] spids: [-1 252] ) ] spids: [-1 263] ) (If arms: [ (if_arm cond: [(C {(test)} {($ VSub_Name "$type")} {(Lit_Other "=")} {(basic)})] action: [ (SimpleCommand words: [{(git)} {(rev-list)} {($ VSub_Name "$arg")}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(test.actual)} spids: [286] ) ] ) ] spids: [-1 277] ) (if_arm cond: [(C {(test)} {($ VSub_Name "$type")} {(Lit_Other "=")} {(parents)})] action: [ (SimpleCommand words: [{(git)} {(rev-list)} {(--parents)} {($ VSub_Name "$arg")}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(test.actual)} spids: [312] ) ] ) ] spids: [290 301] ) (if_arm cond: [(C {(test)} {($ VSub_Name "$type")} {(Lit_Other "=")} {(parents-raw)})] action: [ (Pipeline children: [ (C {(git)} {(rev-list)} {(--parents)} {(--pretty) (Lit_Other "=") (raw)} {($ VSub_Name "$arg")} ) (SimpleCommand words: [{(sed)} {(-n)} {(-e)} {(SQ <"s/^commit //p">)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(test.actual)} spids: [355] ) ] ) ] negated: False ) ] spids: [316 327] ) ] spids: [-1 359] ) (C {(test_cmp)} {(test.expect)} {(test.actual)}) ] spids: [60] ) spids: [55 59] ) (ForEach iter_name: type iter_words: [{(basic)} {(parents)} {(parents-raw)}] do_arg_iter: False body: (DoGroup children: [ (C {(test_expect_success)} {(SQ <"without grafts">)} { (DQ ("\n") ("\t\trm -f .git/info/grafts &&\n") ("\t\tcheck ") ($ VSub_Name "$type") (" ") ($ VSub_Name "$B2") (" -- ") ($ VSub_Name "$B2") (" ") ($ VSub_Name "$B1") (" ") ($ VSub_Name "$B0") ("\n") ("\t") ) } ) (C {(test_expect_success)} {(SQ <"with grafts">)} { (DQ ("\n") ("\t\techo '") ($ VSub_Name "$B0") (" ") ($ VSub_Name "$A2") ("' >.git/info/grafts &&\n") ("\t\tcheck ") ($ VSub_Name "$type") (" ") ($ VSub_Name "$B2") (" -- ") ($ VSub_Name "$B2") (" ") ($ VSub_Name "$B1") (" ") ($ VSub_Name "$B0") (" ") ($ VSub_Name "$A2") (" ") ($ VSub_Name "$A1") (" ") ($ VSub_Name "$A0") ("\n") ("\t") ) } ) (C {(test_expect_success)} {(SQ <"without grafts, with pathlimit">)} { (DQ ("\n") ("\t\trm -f .git/info/grafts &&\n") ("\t\tcheck ") ($ VSub_Name "$type") (" ") ($ VSub_Name "$B2") (" subdir -- ") ($ VSub_Name "$B2") (" ") ($ VSub_Name "$B0") ("\n") ("\t") ) } ) (C {(test_expect_success)} {(SQ <"with grafts, with pathlimit">)} { (DQ ("\n") ("\t\techo '") ($ VSub_Name "$B0") (" ") ($ VSub_Name "$A2") ("' >.git/info/grafts &&\n") ("\t\tcheck ") ($ VSub_Name "$type") (" ") ($ VSub_Name "$B2") (" subdir -- ") ($ VSub_Name "$B2") (" ") ($ VSub_Name "$B0") (" ") ($ VSub_Name "$A2") (" ") ($ VSub_Name "$A0") ("\n") ("\t") ) } ) ] spids: [383 499] ) spids: [376 -1] ) (C {(test_done)}) ] )