#!/bin/sh global test_description := ''refspec parsing'' source ./test-lib.sh proc test_refspec { global kind := $1, refspec := $2, expect := $3 git config remote.frotz.url "." && git config --remove-section remote.frotz && git config remote.frotz.url "." && git config "remote.frotz.$kind" $refspec && if test $expect != invalid { global title := ""$kind $refspec"" global test := ''git ls-remote frotz'' } else { global title := ""$kind $refspec (invalid)"" global test := ''test_must_fail git ls-remote frotz'' } test_expect_success $title $test } test_refspec push '' invalid test_refspec push ':' test_refspec push '::' invalid test_refspec push '+:' test_refspec fetch '' test_refspec fetch ':' test_refspec fetch '::' invalid test_refspec push 'refs/heads/*:refs/remotes/frotz/*' test_refspec push 'refs/heads/*:refs/remotes/frotz' invalid test_refspec push 'refs/heads:refs/remotes/frotz/*' invalid test_refspec push 'refs/heads/master:refs/remotes/frotz/xyzzy' # These have invalid LHS, but we do not have a formal "valid sha-1 # expression syntax checker" so they are not checked with the current # code. They will be caught downstream anyway, but we may want to # have tighter check later... : test_refspec push 'refs/heads/master::refs/remotes/frotz/xyzzy' invalid : test_refspec push 'refs/heads/maste :refs/remotes/frotz/xyzzy' invalid test_refspec fetch 'refs/heads/*:refs/remotes/frotz/*' test_refspec fetch 'refs/heads/*:refs/remotes/frotz' invalid test_refspec fetch 'refs/heads:refs/remotes/frotz/*' invalid test_refspec fetch 'refs/heads/master:refs/remotes/frotz/xyzzy' test_refspec fetch 'refs/heads/master::refs/remotes/frotz/xyzzy' invalid test_refspec fetch 'refs/heads/maste :refs/remotes/frotz/xyzzy' invalid test_refspec push 'master~1:refs/remotes/frotz/backup' test_refspec fetch 'master~1:refs/remotes/frotz/backup' invalid test_refspec push 'HEAD~4:refs/remotes/frotz/new' test_refspec fetch 'HEAD~4:refs/remotes/frotz/new' invalid test_refspec push 'HEAD' test_refspec fetch 'HEAD' test_refspec push 'refs/heads/ nitfol' invalid test_refspec fetch 'refs/heads/ nitfol' invalid test_refspec push 'HEAD:' invalid test_refspec fetch 'HEAD:' test_refspec push 'refs/heads/ nitfol:' invalid test_refspec fetch 'refs/heads/ nitfol:' invalid test_refspec push ':refs/remotes/frotz/deleteme' test_refspec fetch ':refs/remotes/frotz/HEAD-to-me' test_refspec push ':refs/remotes/frotz/delete me' invalid test_refspec fetch ':refs/remotes/frotz/HEAD to me' invalid test_refspec fetch 'refs/heads/*/for-linus:refs/remotes/mine/*-blah' test_refspec push 'refs/heads/*/for-linus:refs/remotes/mine/*-blah' test_refspec fetch 'refs/heads*/for-linus:refs/remotes/mine/*' test_refspec push 'refs/heads*/for-linus:refs/remotes/mine/*' test_refspec fetch 'refs/heads/*/*/for-linus:refs/remotes/mine/*' invalid test_refspec push 'refs/heads/*/*/for-linus:refs/remotes/mine/*' invalid test_refspec fetch 'refs/heads/*g*/for-linus:refs/remotes/mine/*' invalid test_refspec push 'refs/heads/*g*/for-linus:refs/remotes/mine/*' invalid test_refspec fetch 'refs/heads/*/for-linus:refs/remotes/mine/*' test_refspec push 'refs/heads/*/for-linus:refs/remotes/mine/*' global good := $[printf '\303\204] test_refspec fetch "refs/heads/$(good)" global bad := $[printf '\011tab] test_refspec fetch "refs/heads/$(bad)" invalid test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"refspec parsing">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: test_refspec body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:kind) op: Equal rhs: {($ VSub_Number "$1")} spids: [23] ) (assign_pair lhs: (LhsName name:refspec) op: Equal rhs: {($ VSub_Number "$2")} spids: [26] ) (assign_pair lhs: (LhsName name:expect) op: Equal rhs: {($ VSub_Number "$3")} spids: [29] ) ] spids: [23] ) (AndOr children: [ (C {(git)} {(config)} {(remote.frotz.url)} {(DQ (.))}) (AndOr children: [ (C {(git)} {(config)} {(--remove-section)} {(remote.frotz)}) (AndOr children: [ (C {(git)} {(config)} {(remote.frotz.url)} {(DQ (.))}) (AndOr children: [ (C {(git)} {(config)} {(DQ (remote.frotz.) ($ VSub_Name "$kind"))} {(DQ ($ VSub_Name "$refspec"))} ) (If arms: [ (if_arm cond: [ (C {(test)} {(DQ ($ VSub_Name "$expect"))} {(KW_Bang "!") (Lit_Other "=")} {(invalid)} ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:title) op: Equal rhs: { (DQ ($ VSub_Name "$kind") (" ") ($ VSub_Name "$refspec")) } spids: [103] ) ] spids: [103] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test) op: Equal rhs: {(SQ <"git ls-remote frotz">)} spids: [111] ) ] spids: [111] ) ] spids: [-1 100] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:title) op: Equal rhs: { (DQ ($ VSub_Name "$kind") (" ") ($ VSub_Name "$refspec") (" (invalid)") ) } spids: [120] ) ] spids: [120] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test) op: Equal rhs: {(SQ <"test_must_fail git ls-remote frotz">)} spids: [129] ) ] spids: [129] ) ] spids: [117 135] ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) (C {(test_expect_success)} {(DQ ($ VSub_Name "$title"))} {(DQ ($ VSub_Name "$test"))}) ] spids: [20] ) spids: [15 19] ) (C {(test_refspec)} {(push)} {(SQ )} {(invalid)}) (C {(test_refspec)} {(push)} {(SQ <":">)}) (C {(test_refspec)} {(push)} {(SQ <"::">)} {(invalid)}) (C {(test_refspec)} {(push)} {(SQ <"+:">)}) (C {(test_refspec)} {(fetch)} {(SQ )}) (C {(test_refspec)} {(fetch)} {(SQ <":">)}) (C {(test_refspec)} {(fetch)} {(SQ <"::">)} {(invalid)}) (C {(test_refspec)} {(push)} {(SQ <"refs/heads/*:refs/remotes/frotz/*">)}) (C {(test_refspec)} {(push)} {(SQ <"refs/heads/*:refs/remotes/frotz">)} {(invalid)}) (C {(test_refspec)} {(push)} {(SQ <"refs/heads:refs/remotes/frotz/*">)} {(invalid)}) (C {(test_refspec)} {(push)} {(SQ <"refs/heads/master:refs/remotes/frotz/xyzzy">)}) (C {(Lit_Other ":")} {(test_refspec)} {(push)} {(SQ <"refs/heads/master::refs/remotes/frotz/xyzzy">)} {(invalid)} ) (C {(Lit_Other ":")} {(test_refspec)} {(push)} {(SQ <"refs/heads/maste :refs/remotes/frotz/xyzzy">)} {(invalid)} ) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads/*:refs/remotes/frotz/*">)}) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads/*:refs/remotes/frotz">)} {(invalid)}) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads:refs/remotes/frotz/*">)} {(invalid)}) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads/master:refs/remotes/frotz/xyzzy">)}) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads/master::refs/remotes/frotz/xyzzy">)} {(invalid)}) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads/maste :refs/remotes/frotz/xyzzy">)} {(invalid)}) (C {(test_refspec)} {(push)} {(SQ <"master~1:refs/remotes/frotz/backup">)}) (C {(test_refspec)} {(fetch)} {(SQ <"master~1:refs/remotes/frotz/backup">)} {(invalid)}) (C {(test_refspec)} {(push)} {(SQ <"HEAD~4:refs/remotes/frotz/new">)}) (C {(test_refspec)} {(fetch)} {(SQ <"HEAD~4:refs/remotes/frotz/new">)} {(invalid)}) (C {(test_refspec)} {(push)} {(SQ
)}) (C {(test_refspec)} {(fetch)} {(SQ )}) (C {(test_refspec)} {(push)} {(SQ <"refs/heads/ nitfol">)} {(invalid)}) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads/ nitfol">)} {(invalid)}) (C {(test_refspec)} {(push)} {(SQ <"HEAD:">)} {(invalid)}) (C {(test_refspec)} {(fetch)} {(SQ <"HEAD:">)}) (C {(test_refspec)} {(push)} {(SQ <"refs/heads/ nitfol:">)} {(invalid)}) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads/ nitfol:">)} {(invalid)}) (C {(test_refspec)} {(push)} {(SQ <":refs/remotes/frotz/deleteme">)}) (C {(test_refspec)} {(fetch)} {(SQ <":refs/remotes/frotz/HEAD-to-me">)}) (C {(test_refspec)} {(push)} {(SQ <":refs/remotes/frotz/delete me">)} {(invalid)}) (C {(test_refspec)} {(fetch)} {(SQ <":refs/remotes/frotz/HEAD to me">)} {(invalid)}) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads/*/for-linus:refs/remotes/mine/*-blah">)}) (C {(test_refspec)} {(push)} {(SQ <"refs/heads/*/for-linus:refs/remotes/mine/*-blah">)}) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads*/for-linus:refs/remotes/mine/*">)}) (C {(test_refspec)} {(push)} {(SQ <"refs/heads*/for-linus:refs/remotes/mine/*">)}) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads/*/*/for-linus:refs/remotes/mine/*">)} {(invalid)}) (C {(test_refspec)} {(push)} {(SQ <"refs/heads/*/*/for-linus:refs/remotes/mine/*">)} {(invalid)}) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads/*g*/for-linus:refs/remotes/mine/*">)} {(invalid)}) (C {(test_refspec)} {(push)} {(SQ <"refs/heads/*g*/for-linus:refs/remotes/mine/*">)} {(invalid)}) (C {(test_refspec)} {(fetch)} {(SQ <"refs/heads/*/for-linus:refs/remotes/mine/*">)}) (C {(test_refspec)} {(push)} {(SQ <"refs/heads/*/for-linus:refs/remotes/mine/*">)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:good) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(printf)} {(SQ <"\\303\\204">)})]) left_token: