# Re: git tag: don't complain of empty messages

10 messages from 2006-11-15 to 2006-11-26. Participants: Han-Wen Nienhuys, Johannes Schindelin, Junio C Hamano, Jakub Narebski.
Thread: https://gitlist.dev/t/43073

## Han-Wen Nienhuys, 2006-11-15 15:34

Subject: git tag: don't complain of empty messages
Message-ID: <ejfc1t$6am$1@sea.gmane.org>
URL: https://gitlist.dev/e/ejfc1t%246am%241%40sea.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
     }

```

## Johannes Schindelin, 2006-11-15 16:02

Subject: Re: git tag: don't complain of empty messages
Message-ID: <Pine.LNX.4.63.0611151657570.13772@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0611151657570.13772%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <ejfc1t$6am$1@sea.gmane.org>

```
Hi,

On Wed, 15 Nov 2006, Han-Wen Nienhuys wrote:

> 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.

I think that this behaviour is on purpose: The tag will be identified 
(like all objects in git) by its contents. The rationale: the filename 
does not matter, since the tag _object_ is not identified by it. So, in 
case you lose your .git/refs/tags/ directory, you can still reconstruct 
the tags with "git-fsck-objects --full".

Ciao,
Dscho

```

## Han-Wen Nienhuys, 2006-11-15 16:05

Subject: Re: git tag: don't complain of empty messages
Message-ID: <455B3AC2.10107@xs4all.nl>
URL: https://gitlist.dev/e/455B3AC2.10107%40xs4all.nl
In-Reply-To: <Pine.LNX.4.63.0611151657570.13772@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin escreveu:
> Hi,
> 
> On Wed, 15 Nov 2006, Han-Wen Nienhuys wrote:
> 
>> 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.
> 
> I think that this behaviour is on purpose: The tag will be identified 
> (like all objects in git) by its contents. The rationale: the filename 
> does not matter, since the tag _object_ is not identified by it. So, in 
> case you lose your .git/refs/tags/ directory, you can still reconstruct 
> the tags with "git-fsck-objects --full".

Without a message, the tag can still be identified by its name, which is 
in the tag object contents.

-- 

```

## Johannes Schindelin, 2006-11-15 16:19

Subject: Re: git tag: don't complain of empty messages
Message-ID: <Pine.LNX.4.63.0611151718220.13772@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0611151718220.13772%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <455B3AC2.10107@xs4all.nl>

```
Hi,

On Wed, 15 Nov 2006, Han-Wen Nienhuys wrote:

> Without a message, the tag can still be identified by its name, which is 
> in the tag object contents.

You are correct. Acked-by: me.

Ciao,
Dscho

```

## Junio C Hamano, 2006-11-15 18:23

Subject: Re: git tag: don't complain of empty messages
Message-ID: <7v64dgo9gj.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v64dgo9gj.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <ejfc1t$6am$1@sea.gmane.org>

```
Han-Wen Nienhuys <hanwen@xs4all.nl> writes:

> 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
>

Please follow Documentation/SubmittingPatches.

> 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

If you are going to do this, this hunk should be changed to
check if the command line ended with "-m" without next
parameter, in which case it should error out.

I do not have a strong objection against allowing tags without
messages, but at the same time I do not see a compelling reason
to allow them either.  Care to explain what workflow is helped
by an empty tag?

```

## Han-Wen Nienhuys, 2006-11-16 00:14

Subject: Re: git tag: don't complain of empty messages
Message-ID: <455BAD80.1080108@xs4all.nl>
URL: https://gitlist.dev/e/455BAD80.1080108%40xs4all.nl
In-Reply-To: <7v64dgo9gj.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano escreveu:
> I do not have a strong objection against allowing tags without
> messages, but at the same time I do not see a compelling reason
> to allow them either.  Care to explain what workflow is helped
> by an empty tag?

the tagname usually is enough of a description, but I want the tags to 
end up in the object DB, eg.:

   git tag release/2.10.0 HEAD

now I have to use

   git tag -m "this really sucks"  release/2.10.0 HEAD


-- 

```

## Jakub Narebski, 2006-11-16 00:38

Subject: Re: git tag: don't complain of empty messages
Message-ID: <ejgbrq$o5u$1@sea.gmane.org>
URL: https://gitlist.dev/e/ejgbrq%24o5u%241%40sea.gmane.org
In-Reply-To: <455BAD80.1080108@xs4all.nl>

```
Han-Wen Nienhuys wrote:

> Junio C Hamano escreveu:
>> I do not have a strong objection against allowing tags without
>> messages, but at the same time I do not see a compelling reason
>> to allow them either.  Care to explain what workflow is helped
>> by an empty tag?
> 
> the tagname usually is enough of a description, but I want the tags to 
> end up in the object DB, eg.:
> 
>    git tag release/2.10.0 HEAD
> 
> now I have to use
> 
>    git tag -m "this really sucks"  release/2.10.0 HEAD

Why not

   git tag -m "release 2.10.0" release/2.10.0 HEAD

This way you would know what tag points to even if you loose it's
reference...
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


```

## Han-Wen Nienhuys, 2006-11-16 01:27

Subject: Re: git tag: don't complain of empty messages
Message-ID: <455BBE89.6070005@xs4all.nl>
URL: https://gitlist.dev/e/455BBE89.6070005%40xs4all.nl
In-Reply-To: <ejgbrq$o5u$1@sea.gmane.org>

```
Jakub Narebski escreveu:
> Han-Wen Nienhuys wrote:
> 
>> Junio C Hamano escreveu:
>>> I do not have a strong objection against allowing tags without
>>> messages, but at the same time I do not see a compelling reason
>>> to allow them either.  Care to explain what workflow is helped
>>> by an empty tag?
>> the tagname usually is enough of a description, but I want the tags to 
>> end up in the object DB, eg.:
>>
>>    git tag release/2.10.0 HEAD
>>
>> now I have to use
>>
>>    git tag -m "this really sucks"  release/2.10.0 HEAD
> 
> Why not
> 
>    git tag -m "release 2.10.0" release/2.10.0 HEAD
> 
> This way you would know what tag points to even if you loose it's
> reference...

that would double, given that the tag name is already in the tag object. 
Currently, I have

**
[lilydev@haring gub]$ cat .git/refs/tags/gubrelease-2.9.29-2
1ac5c78609a9f79787825b62c9576542eedce795


[lilydev@haring gub]$ git cat-file tag 
1ac5c78609a9f79787825b62c9576542eedce795


object b75db784e3d6a9e1d2cff3f77036aaa88598b53c
type commit
tag gub-2.9.29-2
tagger Han-Wen Nienhuys <lilydev@haring.localdomain> 1162921716 +0100

build and upload
**

'build and upload' is a polite way of saying 'this really sucks'.

-- 
  Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen

```

## Han-Wen Nienhuys, 2006-11-26 16:42

Subject: Re: git tag: don't complain of empty messages
Message-ID: <4569C409.5080509@xs4all.nl>
URL: https://gitlist.dev/e/4569C409.5080509%40xs4all.nl
In-Reply-To: <7v64dgo9gj.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano escreveu:
> Please follow Documentation/SubmittingPatches.

See below, hope I didn't mess up.



From be40730d19592f9db8f07f619f5723060c2f4f0c Mon Sep 17 00:00:00 2001
From: Han-Wen Nienhuys <hanwen@lilypond.org>
Date: Sun, 26 Nov 2006 17:41:30 +0100
Subject: [PATCH] allow empty tag message if -m is given explicitly.

---
 git-tag.sh |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/git-tag.sh b/git-tag.sh
index ac269e3..d53f94c 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,12 @@ do
     	annotate=1
 	shift
 	message="$1"
+	if test "$#" = "0"; then
+	    die "error: option -m needs an argument"
+	    exit 2
+	else
+	    message_given=1
+	fi
 	;;
     -u)
 	annotate=1
@@ -83,7 +90,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 +102,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
     }
-- 
1.4.2.4


-- 
 Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen

```

## Han-Wen Nienhuys, 2006-11-26 16:46

Subject: Re: git tag: don't complain of empty messages
Message-ID: <4569C4D3.5060102@xs4all.nl>
URL: https://gitlist.dev/e/4569C4D3.5060102%40xs4all.nl
In-Reply-To: <4569C409.5080509@xs4all.nl>

```
Han-Wen Nienhuys escreveu:
> Junio C Hamano escreveu:
>> Please follow Documentation/SubmittingPatches.
> 
> See below, hope I didn't mess up.

please add

Signed-off-by: Han-Wen Nienhuys <hanwen@xs4all.nl>


-- 
 Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen

```
