2007-01-14 03:37:32 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='test describe
|
|
|
|
|
|
|
|
B
|
|
|
|
.--------------o----o----o----x
|
|
|
|
/ / /
|
|
|
|
o----o----o----o----o----. /
|
|
|
|
\ A c /
|
|
|
|
.------------o---o---o
|
|
|
|
D e
|
|
|
|
'
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
check_describe () {
|
|
|
|
expect="$1"
|
|
|
|
shift
|
2008-03-04 02:09:38 +01:00
|
|
|
R=$(git describe "$@" 2>err.actual)
|
2008-03-04 02:09:31 +01:00
|
|
|
S=$?
|
2008-03-04 02:09:38 +01:00
|
|
|
cat err.actual >&3
|
2007-01-14 03:37:32 +01:00
|
|
|
test_expect_success "describe $*" '
|
2008-03-04 02:09:31 +01:00
|
|
|
test $S = 0 &&
|
2007-01-14 03:37:32 +01:00
|
|
|
case "$R" in
|
|
|
|
$expect) echo happy ;;
|
|
|
|
*) echo "Oops - $R is not $expect";
|
|
|
|
false ;;
|
|
|
|
esac
|
|
|
|
'
|
|
|
|
}
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
|
|
|
|
test_tick &&
|
2007-07-03 07:52:14 +02:00
|
|
|
echo one >file && git add file && git-commit -m initial &&
|
|
|
|
one=$(git rev-parse HEAD) &&
|
2007-01-14 03:37:32 +01:00
|
|
|
|
|
|
|
test_tick &&
|
2007-07-03 07:52:14 +02:00
|
|
|
echo two >file && git add file && git-commit -m second &&
|
|
|
|
two=$(git rev-parse HEAD) &&
|
2007-01-14 03:37:32 +01:00
|
|
|
|
|
|
|
test_tick &&
|
2007-07-03 07:52:14 +02:00
|
|
|
echo three >file && git add file && git-commit -m third &&
|
2007-01-14 03:37:32 +01:00
|
|
|
|
|
|
|
test_tick &&
|
2007-07-03 07:52:14 +02:00
|
|
|
echo A >file && git add file && git-commit -m A &&
|
2007-01-14 03:37:32 +01:00
|
|
|
test_tick &&
|
|
|
|
git-tag -a -m A A &&
|
|
|
|
|
|
|
|
test_tick &&
|
2007-07-03 07:52:14 +02:00
|
|
|
echo c >file && git add file && git-commit -m c &&
|
2007-01-14 03:37:32 +01:00
|
|
|
test_tick &&
|
|
|
|
git-tag c &&
|
|
|
|
|
|
|
|
git reset --hard $two &&
|
|
|
|
test_tick &&
|
2007-07-03 07:52:14 +02:00
|
|
|
echo B >side && git add side && git-commit -m B &&
|
2007-01-14 03:37:32 +01:00
|
|
|
test_tick &&
|
|
|
|
git-tag -a -m B B &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
git-merge -m Merged c &&
|
2007-07-03 07:52:14 +02:00
|
|
|
merged=$(git rev-parse HEAD) &&
|
2007-01-14 03:37:32 +01:00
|
|
|
|
|
|
|
git reset --hard $two &&
|
|
|
|
test_tick &&
|
2007-07-03 07:52:14 +02:00
|
|
|
echo D >another && git add another && git-commit -m D &&
|
2007-01-14 03:37:32 +01:00
|
|
|
test_tick &&
|
|
|
|
git-tag -a -m D D &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
echo DD >another && git commit -a -m another &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
git-tag e &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
echo DDD >another && git commit -a -m "yet another" &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
git-merge -m Merged $merged &&
|
|
|
|
|
|
|
|
test_tick &&
|
2007-07-03 07:52:14 +02:00
|
|
|
echo X >file && echo X >side && git add file side &&
|
2007-01-14 03:37:32 +01:00
|
|
|
git-commit -m x
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
check_describe A-* HEAD
|
|
|
|
check_describe A-* HEAD^
|
|
|
|
check_describe D-* HEAD^^
|
|
|
|
check_describe A-* HEAD^^2
|
|
|
|
check_describe B HEAD^^2^
|
|
|
|
|
|
|
|
check_describe A-* --tags HEAD
|
|
|
|
check_describe A-* --tags HEAD^
|
|
|
|
check_describe D-* --tags HEAD^^
|
|
|
|
check_describe A-* --tags HEAD^^2
|
|
|
|
check_describe B --tags HEAD^^2^
|
|
|
|
|
2008-02-25 10:43:33 +01:00
|
|
|
check_describe B-0-* --long HEAD^^2^
|
2008-03-04 03:29:51 +01:00
|
|
|
check_describe A-3-* --long HEAD^^2
|
2008-02-25 10:43:33 +01:00
|
|
|
|
2008-03-04 02:09:38 +01:00
|
|
|
test_expect_success 'rename tag A to Q locally' '
|
|
|
|
mv .git/refs/tags/A .git/refs/tags/Q
|
|
|
|
'
|
|
|
|
cat - >err.expect <<EOF
|
|
|
|
warning: tag 'A' is really 'Q' here
|
|
|
|
EOF
|
|
|
|
check_describe A-* HEAD
|
|
|
|
test_expect_success 'warning was displayed for Q' '
|
|
|
|
git diff err.expect err.actual
|
|
|
|
'
|
|
|
|
test_expect_success 'rename tag Q back to A' '
|
|
|
|
mv .git/refs/tags/Q .git/refs/tags/A
|
|
|
|
'
|
|
|
|
|
2008-03-04 02:09:35 +01:00
|
|
|
test_expect_success 'pack tag refs' 'git pack-refs'
|
|
|
|
check_describe A-* HEAD
|
|
|
|
|
2007-01-14 03:37:32 +01:00
|
|
|
test_done
|