2007-01-14 10:37:32 +08: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 09:09:38 +08:00
|
|
|
R=$(git describe "$@" 2>err.actual)
|
2008-03-04 09:09:31 +08:00
|
|
|
S=$?
|
2008-03-04 09:09:38 +08:00
|
|
|
cat err.actual >&3
|
2007-01-14 10:37:32 +08:00
|
|
|
test_expect_success "describe $*" '
|
2008-03-04 09:09:31 +08:00
|
|
|
test $S = 0 &&
|
2007-01-14 10:37:32 +08:00
|
|
|
case "$R" in
|
|
|
|
$expect) echo happy ;;
|
|
|
|
*) echo "Oops - $R is not $expect";
|
|
|
|
false ;;
|
|
|
|
esac
|
|
|
|
'
|
|
|
|
}
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
|
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
echo one >file && git add file && git commit -m initial &&
|
2007-07-03 13:52:14 +08:00
|
|
|
one=$(git rev-parse HEAD) &&
|
2007-01-14 10:37:32 +08:00
|
|
|
|
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
echo two >file && git add file && git commit -m second &&
|
2007-07-03 13:52:14 +08:00
|
|
|
two=$(git rev-parse HEAD) &&
|
2007-01-14 10:37:32 +08:00
|
|
|
|
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
echo three >file && git add file && git commit -m third &&
|
2007-01-14 10:37:32 +08:00
|
|
|
|
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
echo A >file && git add file && git commit -m A &&
|
2007-01-14 10:37:32 +08:00
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
git tag -a -m A A &&
|
2007-01-14 10:37:32 +08:00
|
|
|
|
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
echo c >file && git add file && git commit -m c &&
|
2007-01-14 10:37:32 +08:00
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
git tag c &&
|
2007-01-14 10:37:32 +08:00
|
|
|
|
|
|
|
git reset --hard $two &&
|
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
echo B >side && git add side && git commit -m B &&
|
2007-01-14 10:37:32 +08:00
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
git tag -a -m B B &&
|
2007-01-14 10:37:32 +08:00
|
|
|
|
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
git merge -m Merged c &&
|
2007-07-03 13:52:14 +08:00
|
|
|
merged=$(git rev-parse HEAD) &&
|
2007-01-14 10:37:32 +08:00
|
|
|
|
|
|
|
git reset --hard $two &&
|
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
echo D >another && git add another && git commit -m D &&
|
2007-01-14 10:37:32 +08:00
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
git tag -a -m D D &&
|
2007-01-14 10:37:32 +08:00
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
echo DD >another && git commit -a -m another &&
|
|
|
|
|
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
git tag e &&
|
2007-01-14 10:37:32 +08:00
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
echo DDD >another && git commit -a -m "yet another" &&
|
|
|
|
|
|
|
|
test_tick &&
|
2008-09-03 16:59:29 +08:00
|
|
|
git merge -m Merged $merged &&
|
2007-01-14 10:37:32 +08:00
|
|
|
|
|
|
|
test_tick &&
|
2007-07-03 13:52:14 +08:00
|
|
|
echo X >file && echo X >side && git add file side &&
|
2008-09-03 16:59:29 +08:00
|
|
|
git commit -m x
|
2007-01-14 10:37:32 +08:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
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 17:43:33 +08:00
|
|
|
check_describe B-0-* --long HEAD^^2^
|
2008-03-04 10:29:51 +08:00
|
|
|
check_describe A-3-* --long HEAD^^2
|
2008-02-25 17:43:33 +08:00
|
|
|
|
2008-03-04 09:09:38 +08: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' '
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp err.expect err.actual
|
2008-03-04 09:09:38 +08:00
|
|
|
'
|
|
|
|
test_expect_success 'rename tag Q back to A' '
|
|
|
|
mv .git/refs/tags/Q .git/refs/tags/A
|
|
|
|
'
|
|
|
|
|
2008-03-04 09:09:35 +08:00
|
|
|
test_expect_success 'pack tag refs' 'git pack-refs'
|
|
|
|
check_describe A-* HEAD
|
|
|
|
|
2008-06-05 03:06:31 +08:00
|
|
|
test_expect_success 'set-up matching pattern tests' '
|
|
|
|
git tag -a -m test-annotated test-annotated &&
|
|
|
|
echo >>file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -a -m "one more" &&
|
|
|
|
git tag test1-lightweight &&
|
|
|
|
echo >>file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -a -m "yet another" &&
|
|
|
|
git tag test2-lightweight &&
|
|
|
|
echo >>file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -a -m "even more"
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
check_describe "test-annotated-*" --match="test-*"
|
|
|
|
|
|
|
|
check_describe "test1-lightweight-*" --tags --match="test1-*"
|
|
|
|
|
|
|
|
check_describe "test2-lightweight-*" --tags --match="test2-*"
|
|
|
|
|
2008-07-03 10:32:45 +08:00
|
|
|
check_describe "test2-lightweight-*" --long --tags --match="test2-*" HEAD^
|
|
|
|
|
2007-01-14 10:37:32 +08:00
|
|
|
test_done
|