: included from 6002 and others mkdir -p .git/refs/tags >sed.script # Answer the sha1 has associated with the tag. The tag must exist in .git/refs/tags proc tag { global _tag := $1 test -f ".git/refs/tags/$_tag" || error "tag: \"$_tag\" does not exist" cat ".git/refs/tags/$_tag" } # Generate a commit using the text specified to make it unique and the tree # named by the tag specified. proc unique_commit { global _text := $1 global _tree := $2 shift 2 echo $_text | git commit-tree $[tag $_tree] @Argv } # Save the output of a command into the tag specified. Prepend # a substitution script for the tag onto the front of sed.script proc save_tag { global _tag := $1 test -n $_tag || error "usage: save_tag tag commit-args ..." shift 1 @Argv >".git/refs/tags/$_tag" echo "s/$[tag $_tag]/$_tag/g" >sed.script.tmp cat sed.script >>sed.script.tmp rm sed.script mv sed.script.tmp sed.script } # Replace unhelpful sha1 hashes with their symbolic equivalents proc entag { sed -f sed.script } # Execute a command after first saving, then setting the GIT_AUTHOR_EMAIL # tag to a specified value. Restore the original value on return. proc as_author { global _author := $1 shift 1 global _save := $GIT_AUTHOR_EMAIL global GIT_AUTHOR_EMAIL := $_author export GIT_AUTHOR_EMAIL @Argv if test -z $_save { unset GIT_AUTHOR_EMAIL } else { global GIT_AUTHOR_EMAIL := $_save export GIT_AUTHOR_EMAIL } } proc commit_date { global _commit := $1 git cat-file commit $_commit | sed -n "s/^committer .*> \([0-9]*\) .*/\1/p" } # Assign the value of fake date to a variable, but # allow fairly common "1971-08-16 00:00" to be omittd proc assign_fake_date { matchstr $2 { ??:??:?? { eval "$1='1971-08-16 $2'" } ??:?? { eval "$1='1971-08-16 00:$2'" } ?? { eval "$1='1971-08-16 00:00:$2'" } * { eval "$1='$2'" } } } proc on_committer_date { assign_fake_date GIT_COMMITTER_DATE $1 export GIT_COMMITTER_DATE shift 1 @Argv } proc on_dates { assign_fake_date GIT_COMMITTER_DATE $1 assign_fake_date GIT_AUTHOR_DATE $2 export GIT_COMMITTER_DATE GIT_AUTHOR_DATE shift 2 @Argv } # Execute a command and suppress any error output. proc hide_error { @Argv !2 >/dev/null } proc check_output { global _name := $1 shift 1 if eval "$ifsjoin(Argv)" | entag >"$_name.actual" { test_cmp "$_name.expected" "$_name.actual" } else { return 1 } } # Turn a reasonable test description into a reasonable test name. # All alphanums translated into -'s which are then compressed and stripped # from front and back. proc name_from_description { perl -pe ' s/[^A-Za-z0-9.]/-/g; s/-+/-/g; s/-$//; s/^-//; y/A-Z/a-z/; ' } # Execute the test described by the first argument, by eval'ing # command line specified in the 2nd argument. Check the status code # is zero and that the output matches the stream read from # stdin. proc test_output_expect_success { global _description := $1 global _test := $2 test $Argc -eq 2 || error "usage: test_output_expect_success description test <"$_name.expected" test_expect_success $_description "check_output $_name \"$_test\"" } (CommandList children: [ (C {(Lit_Other ":")} {(included)} {(from)} {(6002)} {(and)} {(others)}) (C {(mkdir)} {(-p)} {(.git/refs/tags)}) (SimpleCommand redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(sed.script)} spids:[20])] ) (FuncDef name: tag body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_tag) op: Equal rhs: {($ VSub_Number "$1")} spids: [35] ) ] spids: [35] ) (AndOr children: [ (C {(test)} {(-f)} {(DQ (.git/refs/tags/) ($ VSub_Name "$_tag"))}) (C {(error)} { (DQ ("tag: ") (EscapedLiteralPart token:) ($ VSub_Name "$_tag") (EscapedLiteralPart token:) (" does not exist") ) } ) ] op_id: Op_DPipe ) (C {(cat)} {(DQ (.git/refs/tags/) ($ VSub_Name "$_tag"))}) ] spids: [32] ) spids: [27 31] ) (FuncDef name: unique_commit body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_text) op: Equal rhs: {($ VSub_Number "$1")} spids: [85] ) ] spids: [85] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_tree) op: Equal rhs: {($ VSub_Number "$2")} spids: [89] ) ] spids: [89] ) (C {(shift)} {(2)}) (Pipeline children: [ (C {(echo)} {(DQ ($ VSub_Name "$_text"))}) (C {(git)} {(commit-tree)} { (CommandSubPart command_list: (CommandList children: [(C {(tag)} {(DQ ($ VSub_Name "$_tree"))})] ) left_token: spids: [110 116] ) } {(DQ ($ VSub_At "$@"))} ) ] negated: False ) ] spids: [82] ) spids: [77 81] ) (FuncDef name: save_tag body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_tag) op: Equal rhs: {($ VSub_Number "$1")} spids: [139] ) ] spids: [139] ) (AndOr children: [ (C {(test)} {(-n)} {(DQ ($ VSub_Name "$_tag"))}) (C {(error)} {(DQ ("usage: save_tag tag commit-args ..."))}) ] op_id: Op_DPipe ) (C {(shift)} {(1)}) (SimpleCommand words: [{(DQ ($ VSub_At "$@"))}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ (.git/refs/tags/) ($ VSub_Name "$_tag"))} spids: [169] ) ] ) (SimpleCommand words: [ {(echo)} { (DQ (s/) (CommandSubPart command_list: (CommandList children:[(C {(tag)} {($ VSub_Name "$_tag")})]) left_token: spids: [181 185] ) (/) ($ VSub_Name "$_tag") (/g) ) } ] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(sed.script.tmp)} spids:[191])] ) (SimpleCommand words: [{(cat)} {(sed.script)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{(sed.script.tmp)} spids:[199])] ) (C {(rm)} {(sed.script)}) (C {(mv)} {(sed.script.tmp)} {(sed.script)}) ] spids: [136] ) spids: [131 135] ) (FuncDef name: entag body: (BraceGroup children:[(C {(sed)} {(-f)} {(sed.script)})] spids:[225]) spids: [220 224] ) (FuncDef name: as_author body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_author) op: Equal rhs: {($ VSub_Number "$1")} spids: [251] ) ] spids: [251] ) (C {(shift)} {(1)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_save) op: Equal rhs: {($ VSub_Name "$GIT_AUTHOR_EMAIL")} spids: [260] ) ] spids: [260] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GIT_AUTHOR_EMAIL) op: Equal rhs: {(DQ ($ VSub_Name "$_author"))} spids: [265] ) ] spids: [265] ) (C {(export)} {(GIT_AUTHOR_EMAIL)}) (C {(DQ ($ VSub_At "$@"))}) (If arms: [ (if_arm cond: [(C {(test)} {(-z)} {(DQ ($ VSub_Name "$_save"))})] action: [(C {(unset)} {(GIT_AUTHOR_EMAIL)})] spids: [-1 292] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GIT_AUTHOR_EMAIL) op: Equal rhs: {(DQ ($ VSub_Name "$_save"))} spids: [303] ) ] spids: [303] ) (C {(export)} {(GIT_AUTHOR_EMAIL)}) ] spids: [300 314] ) ] spids: [248] ) spids: [243 247] ) (FuncDef name: commit_date body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_commit) op: Equal rhs: {($ VSub_Number "$1")} spids: [327] ) ] spids: [327] ) (Pipeline children: [ (C {(git)} {(cat-file)} {(commit)} {($ VSub_Name "$_commit")}) (C {(sed)} {(-n)} { (DQ ("s/^committer .*> ") (EscapedLiteralPart token:) ("[0-9]*") (EscapedLiteralPart token:) (" .*/") (EscapedLiteralPart token:) (/p) ) } ) ] negated: False ) ] spids: [324] ) spids: [319 323] ) (FuncDef name: assign_fake_date body: (BraceGroup children: [ (Case to_match: {(DQ ($ VSub_Number "$2"))} arms: [ (case_arm pat_list: [ {(Lit_Other "?") (Lit_Other "?") (Lit_Other ":") (Lit_Other "?") (Lit_Other "?") (Lit_Other ":") (Lit_Other "?") (Lit_Other "?") } ] action: [ (C {(eval)} {(DQ ($ VSub_Number "$1") ("='1971-08-16 ") ($ VSub_Number "$2") ("'"))}) ] spids: [382 390 401 -1] ) (case_arm pat_list: [ {(Lit_Other "?") (Lit_Other "?") (Lit_Other ":") (Lit_Other "?") (Lit_Other "?")} ] action: [ (C {(eval)} {(DQ ($ VSub_Number "$1") ("='1971-08-16 00:") ($ VSub_Number "$2") ("'"))} ) ] spids: [404 409 420 -1] ) (case_arm pat_list: [{(Lit_Other "?") (Lit_Other "?")}] action: [ (C {(eval)} {(DQ ($ VSub_Number "$1") ("='1971-08-16 00:00:") ($ VSub_Number "$2") ("'"))} ) ] spids: [423 425 436 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [(C {(eval)} {(DQ ($ VSub_Number "$1") ("='") ($ VSub_Number "$2") ("'"))})] spids: [439 440 451 -1] ) ] spids: [373 379 454] ) ] spids: [370] ) spids: [365 369] ) (FuncDef name: on_committer_date body: (BraceGroup children: [ (C {(assign_fake_date)} {(GIT_COMMITTER_DATE)} {(DQ ($ VSub_Number "$1"))}) (C {(export)} {(GIT_COMMITTER_DATE)}) (C {(shift)} {(1)}) (C {(DQ ($ VSub_At "$@"))}) ] spids: [464] ) spids: [459 463] ) (FuncDef name: on_dates body: (BraceGroup children: [ (C {(assign_fake_date)} {(GIT_COMMITTER_DATE)} {(DQ ($ VSub_Number "$1"))}) (C {(assign_fake_date)} {(GIT_AUTHOR_DATE)} {(DQ ($ VSub_Number "$2"))}) (C {(export)} {(GIT_COMMITTER_DATE)} {(GIT_AUTHOR_DATE)}) (C {(shift)} {(2)}) (C {(DQ ($ VSub_At "$@"))}) ] spids: [498] ) spids: [493 497] ) (FuncDef name: hide_error body: (BraceGroup children: [ (SimpleCommand words: [{(DQ ($ VSub_At "$@"))}] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[553])] ) ] spids: [546] ) spids: [541 545] ) (FuncDef name: check_output body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_name) op: Equal rhs: {($ VSub_Number "$1")} spids: [567] ) ] spids: [567] ) (C {(shift)} {(1)}) (If arms: [ (if_arm cond: [ (Pipeline children: [ (C {(eval)} {(DQ ($ VSub_Star "$*"))}) (SimpleCommand words: [{(entag)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$_name") (.actual))} spids: [588] ) ] ) ] negated: False ) ] action: [ (C {(test_cmp)} {(DQ ($ VSub_Name "$_name") (.expected))} {(DQ ($ VSub_Name "$_name") (.actual))} ) ] spids: [-1 595] ) ] else_action: [(ControlFlow token: arg_word:{(1)})] spids: [611 619] ) ] spids: [564] ) spids: [559 563] ) (FuncDef name: name_from_description body: (BraceGroup children: [ (C {(perl)} {(-pe)} { (SQ <"\n"> <"\t\ts/[^A-Za-z0-9.]/-/g;\n"> <"\t\ts/-+/-/g;\n"> <"\t\ts/-$//;\n"> <"\t\ts/^-//;\n"> <"\t\ty/A-Z/a-z/;\n"> <"\t"> ) } ) ] spids: [638] ) spids: [633 637] ) (FuncDef name: test_output_expect_success body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_description) op: Equal rhs: {($ VSub_Number "$1")} spids: [678] ) ] spids: [678] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_test) op: Equal rhs: {($ VSub_Number "$2")} spids: [682] ) ] spids: [682] ) (AndOr children: [ (C {(test)} {($ VSub_Pound "$#")} {(-eq)} {(2)}) (C {(error)} {(DQ ("usage: test_output_expect_success description test < spids: [706 714] ) } spids: [705] ) ] spids: [705] ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$_name") (.expected))} spids: [719] ) ] ) (C {(test_expect_success)} {(DQ ($ VSub_Name "$_description"))} { (DQ ("check_output ") ($ VSub_Name "$_name") (" ") (EscapedLiteralPart token:) ($ VSub_Name "$_test") (EscapedLiteralPart token:) ) } ) ] spids: [675] ) spids: [671 674] ) ] )