@matheusbsbs / matheus-bagliano / commits / 72bb989d6e
Fork 0

git-tag: Fix "can't shift that many".

This stop git-tag from emitting a "shift: can't shift that many" error, when listing tags. [jc: with further fixups from Sam Vilain merged in; it passes the tests under dash now] Signed-off-by: Alexandre Vassalotti <alexandre@peadrop.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alexandre Vassalotti committed Jun 28, 2007 at 12:56 UTC 72bb989d6e15f1ff443454b5836358ced1dc5bea
1 file changed +24 -5
git-tag.sh
+24 -5
@@ -19,28 +19,40 @@ do
19 case "$1" in
20 -a)
21 annotate=1
22 + shift
23 ;;
24 -s)
25 annotate=1
26 signed=1
27 + shift
28 ;;
29 -f)
30 force=1
31 + shift
32 ;;
33 -n)
31 - case $2 in
32 - -*) LINES=1 # no argument
34 + case "$#,$2" in
35 + 1,* | *,-*)
36 + LINES=1 # no argument
37 ;;
38 *) shift
39 LINES=$(expr "$1" : '\([0-9]*\)')
40 [ -z "$LINES" ] && LINES=1 # 1 line is default when -n is used
41 ;;
42 esac
43 + shift
44 ;;
45 -l)
46 list=1
47 shift
43 - PATTERN="$1" # select tags by shell pattern, not re
48 + case $# in
49 + 0) PATTERN=
50 + ;;
51 + *)
52 + PATTERN="$1" # select tags by shell pattern, not re
53 + shift
54 + ;;
55 + esac
56 git rev-parse --symbolic --tags | sort |
57 while read TAG
58 do
@@ -74,7 +86,9 @@ do
86 if test "$#" = "0"; then
87 die "error: option -m needs an argument"
88 else
89 + message="$1"
90 message_given=1
91 + shift
92 fi
93 ;;
94 -F)
@@ -85,13 +99,19 @@ do
99 else
100 message="$(cat "$1")"
101 message_given=1
102 + shift
103 fi
104 ;;
105 -u)
106 annotate=1
107 signed=1
108 shift
94 - username="$1"
109 + if test "$#" = "0"; then
110 + die "error: option -u needs an argument"
111 + else
112 + username="$1"
113 + shift
114 + fi
115 ;;
116 -d)
117 shift
@@ -126,7 +146,6 @@ do
146 break
147 ;;
148 esac
129 - shift
149 done
150
151 [ -n "$list" ] && exit 0