1 : included from 6002 and others
3 mkdir -p .git/refs/tags
7 # Answer the sha1 has associated with the tag. The tag must exist in .git/refs/tags
10 test -f ".git/refs/tags/$_tag" || error "tag: \"$_tag\" does not exist"
11 cat ".git/refs/tags/$_tag"
14 # Generate a commit using the text specified to make it unique and the tree
15 # named by the tag specified.
20 echo "$_text" | git commit-tree $(tag "$_tree") "$@"
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
27 test -n "$_tag" || error "usage: save_tag tag commit-args ..."
29 "$@" >".git/refs/tags/$_tag"
31 echo "s/$(tag $_tag)/$_tag/g" >sed.script.tmp
32 cat sed.script >>sed.script.tmp
34 mv sed.script.tmp sed.script
37 # Replace unhelpful sha1 hashes with their symbolic equivalents
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.
47 _save=$GIT_AUTHOR_EMAIL
49 GIT_AUTHOR_EMAIL="$_author"
50 export GIT_AUTHOR_EMAIL
54 unset GIT_AUTHOR_EMAIL
56 GIT_AUTHOR_EMAIL="$_save"
57 export GIT_AUTHOR_EMAIL
63 git cat-file commit $_commit |
64 sed -n "s/^committer .*> \([0-9]*\) .*/\1/p"
67 # Assign the value of fake date to a variable, but
68 # allow fairly common "1971-08-16 00:00" to be omittd
71 ??:??:??) eval "$1='1971-08-16 $2'" ;;
72 ??:??) eval "$1='1971-08-16 00:$2'" ;;
73 ??) eval "$1='1971-08-16 00:00:$2'" ;;
78 on_committer_date () {
79 assign_fake_date GIT_COMMITTER_DATE "$1"
80 export GIT_COMMITTER_DATE
86 assign_fake_date GIT_COMMITTER_DATE "$1"
87 assign_fake_date GIT_AUTHOR_DATE "$2"
88 export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
93 # Execute a command and suppress any error output.
101 if eval "$*" | entag >"$_name.actual"
103 test_cmp "$_name.expected" "$_name.actual"
109 # Turn a reasonable test description into a reasonable test name.
110 # All alphanums translated into -'s which are then compressed and stripped
111 # from front and back.
112 name_from_description () {
123 # Execute the test described by the first argument, by eval'ing
124 # command line specified in the 2nd argument. Check the status code
125 # is zero and that the output matches the stream read from
127 test_output_expect_success()
132 error "usage: test_output_expect_success description test <<EOF ... EOF"
134 _name=$(echo $_description | name_from_description)
135 cat >"$_name.expected"
136 test_expect_success "$_description" "check_output $_name \"$_test\""