(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'check various push.default settings'>)} spids: [4] ) ] ) (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.ShFunction name: check_pushed_commit body: (BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp Id.Op_DAmp] children: [ (command.Simple words: [ {<git>} {<log>} {<-1>} {<--format> <Id.Lit_Equals '='> (SQ <'%h %s'>)} {(DQ ($ Id.VSub_Number '$1'))} ] redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})] do_fork: T ) (command.Simple words: [ {<git>} {<--git-dir> <Id.Lit_Equals '='> (DQ (braced_var_sub token: <Id.VSub_Number 3> suffix_op: (suffix_op.Unary tok: <Id.VTest_ColonHyphen ':-'> arg_word: {<repo1>} ) ) ) } {<log>} {<-1>} {<--format> <Id.Lit_Equals '='> (SQ <'%h %s'>)} {(DQ ($ Id.VSub_Number '$2'))} ] redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<actual>})] do_fork: T ) (C {<test_cmp>} {<expect>} {<actual>}) ] ) ] ) ) (command.ShFunction name: test_push_success body: (BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<git>} { (braced_var_sub token: <Id.VSub_Number 1> suffix_op: (suffix_op.Unary tok:<Id.VTest_ColonPlus ':+'> arg_word:{<-c>}) ) } { (braced_var_sub token: <Id.VSub_Number 1> suffix_op: (suffix_op.Unary tok: <Id.VTest_ColonPlus ':+'> arg_word: {<'push.default='> (DQ ($ Id.VSub_Number '$1'))} ) ) } {<push>} ) (C {<check_pushed_commit>} {<HEAD>} {(DQ ($ Id.VSub_Number '$2'))} {(DQ ($ Id.VSub_Number '$3'))} ) ] ) ] ) ) (command.ShFunction name: test_push_failure body: (BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp] children: [ (command.Simple words: [ {<git>} {<--git-dir> <Id.Lit_Equals '='> <repo1>} {<log>} {<--no-walk>} {<--format> <Id.Lit_Equals '='> (SQ <'%h %s'>)} {<--all>} ] redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})] do_fork: T ) (C {<test_must_fail>} {<git>} { (braced_var_sub token: <Id.VSub_Number 1> suffix_op: (suffix_op.Unary tok:<Id.VTest_ColonPlus ':+'> arg_word:{<-c>}) ) } { (braced_var_sub token: <Id.VSub_Number 1> suffix_op: (suffix_op.Unary tok: <Id.VTest_ColonPlus ':+'> arg_word: {<'push.default='> (DQ ($ Id.VSub_Number '$1'))} ) ) } {<push>} ) (command.Simple words: [ {<git>} {<--git-dir> <Id.Lit_Equals '='> <repo1>} {<log>} {<--no-walk>} {<--format> <Id.Lit_Equals '='> (SQ <'%h %s'>)} {<--all>} ] redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<actual>})] do_fork: T ) (C {<test_cmp>} {<expect>} {<actual>}) ] ) ] ) ) (command.ShFunction name: test_pushdefault_workflow body: (BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:workflow) op: assign_op.Equal rhs: {<central>} spids: [281] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:pushdefault) op: assign_op.Equal rhs: {<parent1>} spids: [285] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<test>} {<-n>} { (DQ (braced_var_sub token: <Id.VSub_Number 4> suffix_op: (suffix_op.Unary tok:<Id.VTest_Hyphen -> arg_word:(word.Empty)) ) ) } ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:workflow) op: assign_op.Equal rhs: {<triangular>} spids: [306] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:pushdefault) op: assign_op.Equal rhs: {<parent2>} spids: [310] ) ] ) ] spids: [289 303] ) ] ) (C {<test_expect_success>} { (DQ <'push.default = '> ($ Id.VSub_Number '$2') <' '> ($ Id.VSub_Number '$1') <' in '> ($ Id.VSub_DollarName '$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 '> ($ Id.VSub_DollarName '$pushdefault') <' &&\n'> <'\t\ttest_commit commit-for-'> ($ Id.VSub_Number '$2') (braced_var_sub token: <Id.VSub_Number 4> suffix_op: (suffix_op.Unary tok:<Id.VTest_Plus '+'> arg_word:{<-triangular>}) ) <' &&\n'> <'\t\ttest_push_'> ($ Id.VSub_Number '$1') <' '> ($ Id.VSub_Number '$2') <' '> ($ Id.VSub_Number '$3') <' '> (braced_var_sub token: <Id.VSub_Number 4> suffix_op: (suffix_op.Unary tok:<Id.VTest_Plus '+'> arg_word:{<repo2>}) ) <'\n'> <'\t'> ) } ) ] ) ) (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>}) ] )