2005-07-06 12:11:24 +02:00
|
|
|
[ -d .git/refs/tags ] || mkdir -p .git/refs/tags
|
|
|
|
|
2005-07-07 02:50:07 +02:00
|
|
|
:> sed.script
|
2005-07-06 12:11:24 +02:00
|
|
|
|
|
|
|
# Answer the sha1 has associated with the tag. The tag must exist in .git or .git/refs/tags
|
|
|
|
tag()
|
|
|
|
{
|
|
|
|
_tag=$1
|
|
|
|
[ -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.
|
|
|
|
unique_commit()
|
|
|
|
{
|
|
|
|
_text=$1
|
|
|
|
_tree=$2
|
|
|
|
shift 2
|
2007-06-07 09:04:01 +02:00
|
|
|
echo $_text | git-commit-tree $(tag $_tree) "$@"
|
2005-07-06 12:11:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Save the output of a command into the tag specified. Prepend
|
2005-07-07 02:50:07 +02:00
|
|
|
# a substitution script for the tag onto the front of sed.script
|
2005-07-06 12:11:24 +02:00
|
|
|
save_tag()
|
|
|
|
{
|
2007-06-07 09:04:01 +02:00
|
|
|
_tag=$1
|
2005-07-06 12:11:24 +02:00
|
|
|
[ -n "$_tag" ] || error "usage: save_tag tag commit-args ..."
|
|
|
|
shift 1
|
2007-06-07 09:04:01 +02:00
|
|
|
"$@" >.git/refs/tags/$_tag
|
2005-07-06 12:11:29 +02:00
|
|
|
|
2005-07-07 02:50:07 +02:00
|
|
|
echo "s/$(tag $_tag)/$_tag/g" > sed.script.tmp
|
|
|
|
cat sed.script >> sed.script.tmp
|
|
|
|
rm sed.script
|
|
|
|
mv sed.script.tmp sed.script
|
2005-07-06 12:11:24 +02:00
|
|
|
}
|
|
|
|
|
2007-06-07 09:04:01 +02:00
|
|
|
# Replace unhelpful sha1 hashses with their symbolic equivalents
|
2005-07-06 12:11:24 +02:00
|
|
|
entag()
|
|
|
|
{
|
2005-07-07 02:50:07 +02:00
|
|
|
sed -f sed.script
|
2005-07-06 12:11:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Execute a command after first saving, then setting the GIT_AUTHOR_EMAIL
|
|
|
|
# tag to a specified value. Restore the original value on return.
|
|
|
|
as_author()
|
|
|
|
{
|
|
|
|
_author=$1
|
|
|
|
shift 1
|
|
|
|
_save=$GIT_AUTHOR_EMAIL
|
|
|
|
|
|
|
|
export GIT_AUTHOR_EMAIL="$_author"
|
|
|
|
"$@"
|
2006-02-08 00:35:46 +01:00
|
|
|
if test -z "$_save"
|
|
|
|
then
|
|
|
|
unset GIT_AUTHOR_EMAIL
|
|
|
|
else
|
|
|
|
export GIT_AUTHOR_EMAIL="$_save"
|
|
|
|
fi
|
2005-07-06 12:11:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
commit_date()
|
|
|
|
{
|
|
|
|
_commit=$1
|
2007-06-07 09:04:01 +02:00
|
|
|
git-cat-file commit $_commit | sed -n "s/^committer .*> \([0-9]*\) .*/\1/p"
|
2005-07-06 12:11:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
on_committer_date()
|
|
|
|
{
|
|
|
|
_date=$1
|
|
|
|
shift 1
|
2006-05-26 04:06:18 +02:00
|
|
|
export GIT_COMMITTER_DATE="$_date"
|
|
|
|
"$@"
|
|
|
|
unset GIT_COMMITTER_DATE
|
2005-07-06 12:11:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Execute a command and suppress any error output.
|
|
|
|
hide_error()
|
|
|
|
{
|
|
|
|
"$@" 2>/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
check_output()
|
|
|
|
{
|
|
|
|
_name=$1
|
|
|
|
shift 1
|
|
|
|
if eval "$*" | entag > $_name.actual
|
|
|
|
then
|
|
|
|
diff $_name.expected $_name.actual
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
name_from_description()
|
|
|
|
{
|
|
|
|
tr "'" '-' | tr '~`!@#$%^&*()_+={}[]|\;:"<>,/? ' '-' | tr -s '-' | tr '[A-Z]' '[a-z]' | sed "s/^-*//;s/-*\$//"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Execute the test described by the first argument, by eval'ing
|
|
|
|
# command line specified in the 2nd argument. Check the status code
|
2007-06-07 09:04:01 +02:00
|
|
|
# is zero and that the output matches the stream read from
|
2005-07-06 12:11:24 +02:00
|
|
|
# stdin.
|
|
|
|
test_output_expect_success()
|
2007-06-07 09:04:01 +02:00
|
|
|
{
|
2005-07-06 12:11:24 +02:00
|
|
|
_description=$1
|
|
|
|
_test=$2
|
|
|
|
[ $# -eq 2 ] || error "usage: test_output_expect_success description test <<EOF ... EOF"
|
|
|
|
_name=$(echo $_description | name_from_description)
|
|
|
|
cat > $_name.expected
|
2007-06-07 09:04:01 +02:00
|
|
|
test_expect_success "$_description" "check_output $_name \"$_test\""
|
2005-07-06 12:11:24 +02:00
|
|
|
}
|