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

git tag: don't complain of empty messages

From
Han-Wen Nienhuys <hanwen@xs4all.nl>
Date
Nov 15, 2006, 15:34 UTC
Message-ID
<ejfc1t$6am$1@sea.gmane.org>
Hello,

GIT refuses to set annotated tags without a comment. I think this is a silly restriction when the message is explicitly set to the empty string.

The attached patch should fix this; Unfortunately, I've been unable to test it. Running the script with sh -x stops at

++exec /home/hanwen/usr/pkg/git/bin/git-sh-setup
-- 
  Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen


commit 446cfbd9edcfaf5fe76f597823e0e3314d091489
Author: Han-Wen Nienhuys <hanwen@lilypond.org>
Date:   Wed Nov 15 16:27:27 2006 +0100

    always set tag if -m is given, even if empty

diff --git a/git-tag.sh b/git-tag.sh
index ac269e3..f2533a3 100755
--- a/git-tag.sh
+++ b/git-tag.sh
@@ -5,6 +5,7 @@ USAGE='-l [<pattern>] | [-a | -s | -u <k
 SUBDIRECTORY_OK='Yes'
 . git-sh-setup
 
+message_given=
 annotate=
 signed=
 force=
@@ -37,6 +38,7 @@ do
     	annotate=1
 	shift
 	message="$1"
+	message_given=1
 	;;
     -u)
 	annotate=1
@@ -83,7 +85,7 @@ tagger=$(git-var GIT_COMMITTER_IDENT) ||
 trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
 
 if [ "$annotate" ]; then
-    if [ -z "$message" ]; then
+    if [ -z "$message_given" ]; then
         ( echo "#"
           echo "# Write a tag message"
           echo "#" ) > "$GIT_DIR"/TAG_EDITMSG
@@ -95,7 +97,7 @@ if [ "$annotate" ]; then
     grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG |
     git-stripspace >"$GIT_DIR"/TAG_FINALMSG
 
-    [ -s "$GIT_DIR"/TAG_FINALMSG ] || {
+    [ -s "$GIT_DIR"/TAG_FINALMSG -o -n "$message_given" ] || {
 	echo >&2 "No tag message?"
 	exit 1
     }
Next: Johannes Schindelin
Message 1 of 10 in “git tag: don't complain of empty messages”
  1. Han-Wen NienhuysNov 15, 2006
  2. Johannes SchindelinNov 15, 2006
  3. Han-Wen NienhuysNov 15, 2006
  4. Johannes SchindelinNov 15, 2006
  5. Junio C HamanoNov 15, 2006
  6. Han-Wen NienhuysNov 16, 2006
  7. Jakub NarebskiNov 16, 2006
  8. Han-Wen NienhuysNov 16, 2006
  9. Han-Wen NienhuysNov 26, 2006
  10. Han-Wen NienhuysNov 26, 2006

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.