git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-tag: Fix the main while loop exit condition.

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 29, 2007, 00:01 UTC
Message-ID
<7vy7i3mxw3.fsf@assigned-by-dhcp.pobox.com>
In-Reply-To
<11830498172717-git-send-email-alexandre@peadrop.com>
Thanks.

I think you would need something like this on top if you want to really fix it, though.

I also suspect that we should error out on:
	$ git tag -l foo bar
but that will be left as an exercise to the readers ;-)
diff --git a/git-tag.sh b/git-tag.sh
index bc0d735..48b54a1 100755
--- a/git-tag.sh
+++ b/git-tag.sh
@@ -14,7 +14,8 @@ username=
 list=
 verify=
 LINES=0
-while [ $# -ne 0 ]; do
+while case "$#" in 0) break ;; esac
+do
     case "$1" in
     -a)
 	annotate=1
@@ -30,8 +31,9 @@ while [ $# -ne 0 ]; do
 	shift
 	;;
     -n)
-        case $2 in
-	-*)	LINES=1 	# no argument
+        case "$#,$2" in
+	1,* | *,-*)
+		LINES=1 	# no argument
 		;;
 	*)	shift
 		LINES=$(expr "$1" : '\([0-9]*\)')
@@ -43,7 +45,14 @@ while [ $# -ne 0 ]; do
     -l)
 	list=1
 	shift
-	PATTERN="$1"	# select tags by shell pattern, not re
+	case $# in
+	0)	PATTERN=
+		;;
+	*)
+		PATTERN="$1"	# select tags by shell pattern, not re
+		shift
+		;;
+	esac
 	git rev-parse --symbolic --tags | sort |
 	    while read TAG
 	    do
Previous: Alexandre VassalottiNext: Sam Vilain
Message 2 of 3 in “git-tag: Fix the main while loop exit condition.”
  1. git-tag: Fix the main while loop exit condition.Alexandre Vassalotti, Jun 28, 2007
  2. Junio C HamanoJun 29, 2007
  3. Sam VilainJun 30, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.