: 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 { setglobal _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 { setglobal _text = $1 setglobal _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 { setglobal _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 { setglobal _author = $1 shift 1 setglobal _save = $GIT_AUTHOR_EMAIL setglobal GIT_AUTHOR_EMAIL = $_author export GIT_AUTHOR_EMAIL @Argv if test -z $_save { unset GIT_AUTHOR_EMAIL } else { setglobal GIT_AUTHOR_EMAIL = $_save export GIT_AUTHOR_EMAIL } } proc commit_date { setglobal _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 { match $2 { with ??:??:?? eval "$1='1971-08-16 $2'" with ??:?? eval "$1='1971-08-16 00:$2'" with ?? eval "$1='1971-08-16 00:00:$2'" with * 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 { setglobal _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 { setglobal _description = $1 setglobal _test = $2 test $Argc -eq 2 || error "usage: test_output_expect_success description test <"$_name.expected" test_expect_success $_description "check_output $_name \"$_test\"" }