1[-d .git/refs/tags ] ||mkdir-p .git/refs/tags 2 3sed_script=""; 4 5# Answer the sha1 has associated with the tag. The tag must exist in .git or .git/refs/tags 6tag() 7{ 8 _tag=$1 9[-f .git/refs/tags/$_tag] || error "tag:\"$_tag\"does not exist" 10cat .git/refs/tags/$_tag 11} 12 13# Generate a commit using the text specified to make it unique and the tree 14# named by the tag specified. 15unique_commit() 16{ 17 _text=$1 18 _tree=$2 19shift2 20echo$_text| git-commit-tree$(tag $_tree)"$@" 21} 22 23# Save the output of a command into the tag specified. Prepend 24# a substitution script for the tag onto the front of $sed_script 25save_tag() 26{ 27 _tag=$1 28[-n"$_tag"] || error "usage: save_tag tag commit-args ..." 29shift1 30"$@">.git/refs/tags/$_tag 31 32 sed_script="s/$(tag $_tag)/$_tag/g 33$sed_script" 34} 35 36# Replace unhelpful sha1 hashses with their symbolic equivalents 37entag() 38{ 39sed"$sed_script" 40} 41 42# Execute a command after first saving, then setting the GIT_AUTHOR_EMAIL 43# tag to a specified value. Restore the original value on return. 44as_author() 45{ 46 _author=$1 47shift1 48 _save=$GIT_AUTHOR_EMAIL 49 50export GIT_AUTHOR_EMAIL="$_author" 51"$@" 52export GIT_AUTHOR_EMAIL="$_save" 53} 54 55commit_date() 56{ 57 _commit=$1 58 git-cat-file commit $_commit|sed-n"s/^committer .*> \([0-9]*\) .*/\1/p" 59} 60 61on_committer_date() 62{ 63 _date=$1 64shift1 65 GIT_COMMITTER_DATE=$_date"$@" 66} 67 68# Execute a command and suppress any error output. 69hide_error() 70{ 71"$@"2>/dev/null 72} 73 74check_output() 75{ 76 _name=$1 77shift1 78ifeval"$*"| entag >$_name.actual 79then 80diff$_name.expected $_name.actual 81else 82return1; 83fi 84} 85 86# Turn a reasonable test description into a reasonable test name. 87# All alphanums translated into -'s which are then compressed and stripped 88# from front and back. 89name_from_description() 90{ 91tr"'"'-'|tr'~`!@#$%^&*()_+={}[]|\;:"<>,/? ''-'|tr-s'-'|tr'[A-Z]''[a-z]'|sed"s/^-*//;s/-*\$//" 92} 93 94 95# Execute the test described by the first argument, by eval'ing 96# command line specified in the 2nd argument. Check the status code 97# is zero and that the output matches the stream read from 98# stdin. 99test_output_expect_success() 100{ 101 _description=$1 102 _test=$2 103[$#-eq2] || error "usage: test_output_expect_success description test <<EOF ... EOF" 104 _name=$(echo $_description | name_from_description) 105cat>$_name.expected 106 test_expect_success "$_description""check_output$_name\"$_test\"" 107}