Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='test describe |
| 4 | |
| 5 | B |
| 6 | .--------------o----o----o----x |
| 7 | / / / |
| 8 | o----o----o----o----o----. / |
| 9 | \ A c / |
| 10 | .------------o---o---o |
| 11 | D e |
| 12 | ' |
| 13 | . ./test-lib.sh |
| 14 | |
| 15 | check_describe () { |
| 16 | expect="$1" |
| 17 | shift |
Shawn O. Pearce | 3291fe4 | 2008-03-03 20:09:38 -0500 | [diff] [blame] | 18 | R=$(git describe "$@" 2>err.actual) |
Shawn O. Pearce | be7bae0 | 2008-03-03 20:09:31 -0500 | [diff] [blame] | 19 | S=$? |
Shawn O. Pearce | 3291fe4 | 2008-03-03 20:09:38 -0500 | [diff] [blame] | 20 | cat err.actual >&3 |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 21 | test_expect_success "describe $*" ' |
Shawn O. Pearce | be7bae0 | 2008-03-03 20:09:31 -0500 | [diff] [blame] | 22 | test $S = 0 && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 23 | case "$R" in |
| 24 | $expect) echo happy ;; |
| 25 | *) echo "Oops - $R is not $expect"; |
| 26 | false ;; |
| 27 | esac |
| 28 | ' |
| 29 | } |
| 30 | |
| 31 | test_expect_success setup ' |
| 32 | |
| 33 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 34 | echo one >file && git add file && git commit -m initial && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 35 | one=$(git rev-parse HEAD) && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 36 | |
| 37 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 38 | echo two >file && git add file && git commit -m second && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 39 | two=$(git rev-parse HEAD) && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 40 | |
| 41 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 42 | echo three >file && git add file && git commit -m third && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 43 | |
| 44 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 45 | echo A >file && git add file && git commit -m A && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 46 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 47 | git tag -a -m A A && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 48 | |
| 49 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 50 | echo c >file && git add file && git commit -m c && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 51 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 52 | git tag c && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 53 | |
| 54 | git reset --hard $two && |
| 55 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 56 | echo B >side && git add side && git commit -m B && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 57 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 58 | git tag -a -m B B && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 59 | |
| 60 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 61 | git merge -m Merged c && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 62 | merged=$(git rev-parse HEAD) && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 63 | |
| 64 | git reset --hard $two && |
| 65 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 66 | echo D >another && git add another && git commit -m D && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 67 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 68 | git tag -a -m D D && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 69 | |
| 70 | test_tick && |
| 71 | echo DD >another && git commit -a -m another && |
| 72 | |
| 73 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 74 | git tag e && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 75 | |
| 76 | test_tick && |
| 77 | echo DDD >another && git commit -a -m "yet another" && |
| 78 | |
| 79 | test_tick && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 80 | git merge -m Merged $merged && |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 81 | |
| 82 | test_tick && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 83 | echo X >file && echo X >side && git add file side && |
Nanako Shiraishi | 3604e7c | 2008-09-03 17:59:29 +0900 | [diff] [blame] | 84 | git commit -m x |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 85 | |
| 86 | ' |
| 87 | |
| 88 | check_describe A-* HEAD |
| 89 | check_describe A-* HEAD^ |
| 90 | check_describe D-* HEAD^^ |
| 91 | check_describe A-* HEAD^^2 |
| 92 | check_describe B HEAD^^2^ |
| 93 | |
Shawn O. Pearce | 7e425c4 | 2008-10-13 07:39:46 -0700 | [diff] [blame] | 94 | check_describe c-* --tags HEAD |
| 95 | check_describe c-* --tags HEAD^ |
| 96 | check_describe e-* --tags HEAD^^ |
| 97 | check_describe c-* --tags HEAD^^2 |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 98 | check_describe B --tags HEAD^^2^ |
| 99 | |
Santi Béjar | 518120e | 2008-02-25 10:43:33 +0100 | [diff] [blame] | 100 | check_describe B-0-* --long HEAD^^2^ |
Junio C Hamano | 4d4c3e1 | 2008-03-03 18:29:51 -0800 | [diff] [blame] | 101 | check_describe A-3-* --long HEAD^^2 |
Santi Béjar | 518120e | 2008-02-25 10:43:33 +0100 | [diff] [blame] | 102 | |
Shawn O. Pearce | 3291fe4 | 2008-03-03 20:09:38 -0500 | [diff] [blame] | 103 | test_expect_success 'rename tag A to Q locally' ' |
| 104 | mv .git/refs/tags/A .git/refs/tags/Q |
| 105 | ' |
| 106 | cat - >err.expect <<EOF |
| 107 | warning: tag 'A' is really 'Q' here |
| 108 | EOF |
| 109 | check_describe A-* HEAD |
| 110 | test_expect_success 'warning was displayed for Q' ' |
Junio C Hamano | 3af8286 | 2008-05-23 22:28:56 -0700 | [diff] [blame] | 111 | test_cmp err.expect err.actual |
Shawn O. Pearce | 3291fe4 | 2008-03-03 20:09:38 -0500 | [diff] [blame] | 112 | ' |
| 113 | test_expect_success 'rename tag Q back to A' ' |
| 114 | mv .git/refs/tags/Q .git/refs/tags/A |
| 115 | ' |
| 116 | |
Shawn O. Pearce | d1b28f5 | 2008-03-03 20:09:35 -0500 | [diff] [blame] | 117 | test_expect_success 'pack tag refs' 'git pack-refs' |
| 118 | check_describe A-* HEAD |
| 119 | |
Michael Dressel | 4ed19a3 | 2008-06-04 21:06:31 +0200 | [diff] [blame] | 120 | test_expect_success 'set-up matching pattern tests' ' |
| 121 | git tag -a -m test-annotated test-annotated && |
| 122 | echo >>file && |
| 123 | test_tick && |
| 124 | git commit -a -m "one more" && |
| 125 | git tag test1-lightweight && |
| 126 | echo >>file && |
| 127 | test_tick && |
| 128 | git commit -a -m "yet another" && |
| 129 | git tag test2-lightweight && |
| 130 | echo >>file && |
| 131 | test_tick && |
| 132 | git commit -a -m "even more" |
| 133 | |
| 134 | ' |
| 135 | |
| 136 | check_describe "test-annotated-*" --match="test-*" |
| 137 | |
| 138 | check_describe "test1-lightweight-*" --tags --match="test1-*" |
| 139 | |
| 140 | check_describe "test2-lightweight-*" --tags --match="test2-*" |
| 141 | |
Shawn O. Pearce | 14d4642 | 2008-07-03 02:32:45 +0000 | [diff] [blame] | 142 | check_describe "test2-lightweight-*" --long --tags --match="test2-*" HEAD^ |
| 143 | |
Junio C Hamano | 5312ab1 | 2007-01-13 18:37:32 -0800 | [diff] [blame] | 144 | test_done |