#!/bin/sh global test_description := ''test @{push} syntax'' source ./test-lib.sh proc resolve { echo $2 >expect && git rev-parse --symbolic-full-name $1 >actual && test_cmp expect actual } test_expect_success 'setup' ' git init --bare parent.git && git init --bare other.git && git remote add origin parent.git && git remote add other other.git && test_commit base && git push origin HEAD && git branch --set-upstream-to=origin/master master && git branch --track topic origin/master && git push origin topic && git push other topic ' test_expect_success '@{push} with default=nothing' ' test_config push.default nothing && test_must_fail git rev-parse master@{push} ' test_expect_success '@{push} with default=simple' ' test_config push.default simple && resolve master@{push} refs/remotes/origin/master ' test_expect_success 'triangular @{push} fails with default=simple' ' test_config push.default simple && test_must_fail git rev-parse topic@{push} ' test_expect_success '@{push} with default=current' ' test_config push.default current && resolve topic@{push} refs/remotes/origin/topic ' test_expect_success '@{push} with default=matching' ' test_config push.default matching && resolve topic@{push} refs/remotes/origin/topic ' test_expect_success '@{push} with pushremote defined' ' test_config push.default current && test_config branch.topic.pushremote other && resolve topic@{push} refs/remotes/other/topic ' test_expect_success '@{push} with push refspecs' ' test_config push.default nothing && test_config remote.origin.push refs/heads/*:refs/heads/magic/* && git push && resolve topic@{push} refs/remotes/origin/magic/topic ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"test @{push} syntax">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: resolve body: (BraceGroup children: [ (AndOr children: [ (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Number "$2"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[28])] ) (AndOr children: [ (SimpleCommand words: [{(git)} {(rev-parse)} {(--symbolic-full-name)} {(DQ ($ VSub_Number "$1"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(actual)} spids:[44])] ) (C {(test_cmp)} {(expect)} {(actual)}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [19] ) spids: [14 18] ) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\tgit init --bare parent.git &&\n"> <"\tgit init --bare other.git &&\n"> <"\tgit remote add origin parent.git &&\n"> <"\tgit remote add other other.git &&\n"> <"\ttest_commit base &&\n"> <"\tgit push origin HEAD &&\n"> <"\tgit branch --set-upstream-to=origin/master master &&\n"> <"\tgit branch --track topic origin/master &&\n"> <"\tgit push origin topic &&\n"> <"\tgit push other topic\n"> ) } ) (C {(test_expect_success)} {(SQ <"@{push} with default=nothing">)} { (SQ <"\n"> <"\ttest_config push.default nothing &&\n"> <"\ttest_must_fail git rev-parse master@{push}\n"> ) } ) (C {(test_expect_success)} {(SQ <"@{push} with default=simple">)} { (SQ <"\n"> <"\ttest_config push.default simple &&\n"> <"\tresolve master@{push} refs/remotes/origin/master\n"> ) } ) (C {(test_expect_success)} {(SQ <"triangular @{push} fails with default=simple">)} { (SQ <"\n"> <"\ttest_config push.default simple &&\n"> <"\ttest_must_fail git rev-parse topic@{push}\n"> ) } ) (C {(test_expect_success)} {(SQ <"@{push} with default=current">)} { (SQ <"\n"> <"\ttest_config push.default current &&\n"> <"\tresolve topic@{push} refs/remotes/origin/topic\n"> ) } ) (C {(test_expect_success)} {(SQ <"@{push} with default=matching">)} { (SQ <"\n"> <"\ttest_config push.default matching &&\n"> <"\tresolve topic@{push} refs/remotes/origin/topic\n"> ) } ) (C {(test_expect_success)} {(SQ <"@{push} with pushremote defined">)} { (SQ <"\n"> <"\ttest_config push.default current &&\n"> <"\ttest_config branch.topic.pushremote other &&\n"> <"\tresolve topic@{push} refs/remotes/other/topic\n"> ) } ) (C {(test_expect_success)} {(SQ <"@{push} with push refspecs">)} { (SQ <"\n"> <"\ttest_config push.default nothing &&\n"> <"\ttest_config remote.origin.push refs/heads/*:refs/heads/magic/* &&\n"> <"\tgit push &&\n"> <"\tresolve topic@{push} refs/remotes/origin/magic/topic\n"> ) } ) (C {(test_done)}) ] )