(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description spids:[12]) op: Equal rhs: {(SQ <'check various push.default settings'>)} spids: [12] ) ] spids: [12] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <'setup bare remotes'>)} { (SQ <'\n'> <'\tgit init --bare repo1 &&\n'> <'\tgit remote add parent1 repo1 &&\n'> <'\tgit init --bare repo2 &&\n'> <'\tgit remote add parent2 repo2 &&\n'> <'\ttest_commit one &&\n'> <'\tgit push parent1 HEAD &&\n'> <'\tgit push parent2 HEAD\n'> ) } ) (command.FuncDef name: check_pushed_commit body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DAmp Op_DAmp] children: [ (command.SimpleCommand words: [ {(git)} {(log)} {(-1)} {(--format) (Lit_Other '=') (SQ <'%h %s'>)} {(DQ ($ VSub_Number '$1'))} ] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect)})] ) (command.SimpleCommand words: [ {(git)} {(--git-dir) (Lit_Other '=') (DQ (word_part.BracedVarSub token: <VSub_Number 3> suffix_op: (suffix_op.StringUnary op_id:VTest_ColonHyphen arg_word:{(repo1)}) spids: [84 88] ) ) } {(log)} {(-1)} {(--format) (Lit_Other '=') (SQ <'%h %s'>)} {(DQ ($ VSub_Number '$2'))} ] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(actual)})] ) (C {(test_cmp)} {(expect)} {(actual)}) ] ) ] spids: [54] ) spids: [49 53] ) (command.FuncDef name: test_push_success body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DAmp] children: [ (C {(git)} { (word_part.BracedVarSub token: <VSub_Number 1> suffix_op: (suffix_op.StringUnary op_id:VTest_ColonPlus arg_word:{(-c)}) spids: [139 143] ) } { (word_part.BracedVarSub token: <VSub_Number 1> suffix_op: (suffix_op.StringUnary op_id: VTest_ColonPlus arg_word: {('push.default=') (DQ ($ VSub_Number '$1'))} ) spids: [145 152] ) } {(push)} ) (C {(check_pushed_commit)} {(HEAD)} {(DQ ($ VSub_Number '$2'))} {(DQ ($ VSub_Number '$3'))} ) ] ) ] spids: [134] ) spids: [129 133] ) (command.FuncDef name: test_push_failure body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DAmp Op_DAmp Op_DAmp] children: [ (command.SimpleCommand words: [ {(git)} {(--git-dir) (Lit_Other '=') (repo1)} {(log)} {(--no-walk)} {(--format) (Lit_Other '=') (SQ <'%h %s'>)} {(--all)} ] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect)})] ) (C {(test_must_fail)} {(git)} { (word_part.BracedVarSub token: <VSub_Number 1> suffix_op: (suffix_op.StringUnary op_id:VTest_ColonPlus arg_word:{(-c)}) spids: [216 220] ) } { (word_part.BracedVarSub token: <VSub_Number 1> suffix_op: (suffix_op.StringUnary op_id: VTest_ColonPlus arg_word: {('push.default=') (DQ ($ VSub_Number '$1'))} ) spids: [222 229] ) } {(push)} ) (command.SimpleCommand words: [ {(git)} {(--git-dir) (Lit_Other '=') (repo1)} {(log)} {(--no-walk)} {(--format) (Lit_Other '=') (SQ <'%h %s'>)} {(--all)} ] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(actual)})] ) (C {(test_cmp)} {(expect)} {(actual)}) ] ) ] spids: [185] ) spids: [180 184] ) (command.FuncDef name: test_pushdefault_workflow body: (command.BraceGroup children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:workflow spids:[289]) op: Equal rhs: {(central)} spids: [289] ) ] spids: [289] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:pushdefault spids:[293]) op: Equal rhs: {(parent1)} spids: [293] ) ] spids: [293] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (C {(test)} {(-n)} { (DQ (word_part.BracedVarSub token: <VSub_Number 4> suffix_op: (suffix_op.StringUnary op_id:VTest_Hyphen arg_word:(word.EmptyWord)) spids: [304 307] ) ) } ) terminator: <Op_Semi ';'> ) ] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:workflow spids:[314]) op: Equal rhs: {(triangular)} spids: [314] ) ] spids: [314] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:pushdefault spids:[318]) op: Equal rhs: {(parent2)} spids: [318] ) ] spids: [318] ) ] spids: [16777215 311] ) ] spids: [16777215 322] ) (C {(test_expect_success)} { (DQ ('push.default = ') ($ VSub_Number '$2') (' ') ($ VSub_Number '$1') (' in ') ($ VSub_Name '$workflow') (' workflows') ) } { (DQ ('\n') ('\t\ttest_config branch.master.remote parent1 &&\n') ('\t\ttest_config branch.master.merge refs/heads/foo &&\n') ('\t\ttest_config remote.pushdefault ') ($ VSub_Name '$pushdefault') (' &&\n') ('\t\ttest_commit commit-for-') ($ VSub_Number '$2') (word_part.BracedVarSub token: <VSub_Number 4> suffix_op: (suffix_op.StringUnary op_id:VTest_Plus arg_word:{(-triangular)}) spids: [346 350] ) (' &&\n') ('\t\ttest_push_') ($ VSub_Number '$1') (' ') ($ VSub_Number '$2') (' ') ($ VSub_Number '$3') (' ') (word_part.BracedVarSub token: <VSub_Number 4> suffix_op: (suffix_op.StringUnary op_id:VTest_Plus arg_word:{(repo2)}) spids: [359 363] ) ('\n') ('\t') ) } ) ] spids: [286] ) spids: [281 285] ) (C {(test_expect_success)} {(SQ <'"upstream" pushes to configured upstream'>)} { (SQ <'\n'> <'\tgit checkout master &&\n'> <'\ttest_config branch.master.remote parent1 &&\n'> <'\ttest_config branch.master.merge refs/heads/foo &&\n'> <'\ttest_commit two &&\n'> <'\ttest_push_success upstream foo\n'> ) } ) (C {(test_expect_success)} {(SQ <'"upstream" does not push on unconfigured remote'>)} { (SQ <'\n'> <'\tgit checkout master &&\n'> <'\ttest_unconfig branch.master.remote &&\n'> <'\ttest_commit three &&\n'> <'\ttest_push_failure upstream\n'> ) } ) (C {(test_expect_success)} {(SQ <'"upstream" does not push on unconfigured branch'>)} { (SQ <'\n'> <'\tgit checkout master &&\n'> <'\ttest_config branch.master.remote parent1 &&\n'> <'\ttest_unconfig branch.master.merge &&\n'> <'\ttest_commit four &&\n'> <'\ttest_push_failure upstream\n'> ) } ) (C {(test_expect_success)} {(SQ <'"upstream" does not push when remotes do not match'>)} { (SQ <'\n'> <'\tgit checkout master &&\n'> <'\ttest_config branch.master.remote parent1 &&\n'> <'\ttest_config branch.master.merge refs/heads/foo &&\n'> <'\ttest_config push.default upstream &&\n'> <'\ttest_commit five &&\n'> <'\ttest_must_fail git push parent2\n'> ) } ) (C {(test_expect_success)} {(SQ <'push from/to new branch with upstream, matching and simple'>)} { (SQ <'\n'> <'\tgit checkout -b new-branch &&\n'> <'\ttest_push_failure simple &&\n'> <'\ttest_push_failure matching &&\n'> <'\ttest_push_failure upstream\n'> ) } ) (C {(test_expect_success)} {(SQ <'push from/to new branch with current creates remote branch'>)} { (SQ <'\n'> <'\ttest_config branch.new-branch.remote repo1 &&\n'> <'\tgit checkout new-branch &&\n'> <'\ttest_push_success current new-branch\n'> ) } ) (C {(test_expect_success)} {(SQ <'push to existing branch, with no upstream configured'>)} { (SQ <'\n'> <'\ttest_config branch.master.remote repo1 &&\n'> <'\tgit checkout master &&\n'> <'\ttest_push_failure simple &&\n'> <'\ttest_push_failure upstream\n'> ) } ) (C {(test_expect_success)} {(SQ <'push to existing branch, upstream configured with same name'>)} { (SQ <'\n'> <'\ttest_config branch.master.remote repo1 &&\n'> <'\ttest_config branch.master.merge refs/heads/master &&\n'> <'\tgit checkout master &&\n'> <'\ttest_commit six &&\n'> <'\ttest_push_success upstream master &&\n'> <'\ttest_commit seven &&\n'> <'\ttest_push_success simple master\n'> ) } ) (C {(test_expect_success)} {(SQ <'push to existing branch, upstream configured with different name'>)} { (SQ <'\n'> <'\ttest_config branch.master.remote repo1 &&\n'> <'\ttest_config branch.master.merge refs/heads/other-name &&\n'> <'\tgit checkout master &&\n'> <'\ttest_commit eight &&\n'> <'\ttest_push_success upstream other-name &&\n'> <'\ttest_commit nine &&\n'> <'\ttest_push_failure simple &&\n'> <'\tgit --git-dir=repo1 log -1 --format="%h %s" "other-name" >expect-other-name &&\n'> <'\ttest_push_success current master &&\n'> <'\tgit --git-dir=repo1 log -1 --format="%h %s" "other-name" >actual-other-name &&\n'> <'\ttest_cmp expect-other-name actual-other-name\n'> ) } ) (C {(test_pushdefault_workflow)} {(success)} {(current)} {(master)}) (C {(test_pushdefault_workflow)} {(success)} {(upstream)} {(foo)}) (C {(test_pushdefault_workflow)} {(failure)} {(simple)} {(master)}) (C {(test_pushdefault_workflow)} {(success)} {(matching)} {(master)}) (C {(test_pushdefault_workflow)} {(success)} {(current)} {(master)} {(triangular)}) (C {(test_pushdefault_workflow)} {(failure)} {(upstream)} {(foo)} {(triangular)}) (C {(test_pushdefault_workflow)} {(success)} {(simple)} {(master)} {(triangular)}) (C {(test_pushdefault_workflow)} {(success)} {(matching)} {(master)} {(triangular)}) (C {(test_expect_success)} {(SQ <'default behavior allows "simple" push'>)} { (SQ <'\n'> <'\ttest_config branch.master.remote parent1 &&\n'> <'\ttest_config branch.master.merge refs/heads/master &&\n'> <'\ttest_config remote.pushdefault parent1 &&\n'> <'\ttest_commit default-master-master &&\n'> <'\ttest_push_success "" master\n'> ) } ) (C {(test_expect_success)} {(SQ <'default behavior rejects non-simple push'>)} { (SQ <'\n'> <'\ttest_config branch.master.remote parent1 &&\n'> <'\ttest_config branch.master.merge refs/heads/foo &&\n'> <'\ttest_config remote.pushdefault parent1 &&\n'> <'\ttest_commit default-master-foo &&\n'> <'\ttest_push_failure ""\n'> ) } ) (C {(test_expect_success)} {(SQ <'default triangular behavior acts like "current"'>)} { (SQ <'\n'> <'\ttest_config branch.master.remote parent1 &&\n'> <'\ttest_config branch.master.merge refs/heads/foo &&\n'> <'\ttest_config remote.pushdefault parent2 &&\n'> <'\ttest_commit default-triangular &&\n'> <'\ttest_push_success "" master repo2\n'> ) } ) (C {(test_done)}) ] )