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

git tag can't take piped input?

From
CWChris Wright <chrisw@osdl.org>
Date
Aug 9, 2005, 00:04 UTC
Message-ID
<20050809000442.GD8041@shell0.pdx.osdl.net>

Apparently I was under a rock sleeping when git-tag-script changed to no longer take input from stdin. So my script which did:

TAG=$(echo "$TAG_MSG" | git-tag-script $RELEASE) echo $TAG > .git/refs/tags/$RELEASE

Is broken in two ways. First it's no longer building an annotated tag, second it creaets a zero length file .git/refs/tags/$RELEASE. Second issue is trivial to fix in my script. First one needs some change in the tag script. Below is a simple patch for a stab at fixing.

thanks, -chris --

Allow users to create a tag message by passing message on command line instead of requiring an $EDITOR session.

Signed-off-by: Chris Wright <chrisw@osdl.org>
---
diff --git a/git-tag-script b/git-tag-script
--- a/git-tag-script
+++ b/git-tag-script
@@ -4,13 +4,14 @@
 . git-sh-setup-script || die "Not a git archive"
 
 usage () {
-    echo >&2 "Usage: git-tag-script [-a | -s] [-f] tagname"
+    echo >&2 "Usage: git-tag-script [-a | -s] [-f] [-m "tag message"] tagname"
     exit 1
 }
 
 annotate=
 signed=
 force=
+message=
 while case "$#" in 0) break ;; esac
 do
     case "$1" in
@@ -24,6 +25,11 @@ do
     -f)
 	force=1
 	;;
+    -m)
+    	annotate=1
+	shift
+	message="$1"
+	;;
     -*)
         usage
 	;;
@@ -48,10 +54,14 @@ tagger=$(git-var GIT_COMMITTER_IDENT) ||
 trap 'rm -f .tmp-tag* .tagmsg .editmsg' 0
 
 if [ "$annotate" ]; then
-    ( echo "#"
-      echo "# Write a tag message"
-      echo "#" ) > .editmsg
-    ${VISUAL:-${EDITOR:-vi}} .editmsg || exit
+    if [ -z "$message" ]; then
+        ( echo "#"
+          echo "# Write a tag message"
+          echo "#" ) > .editmsg
+        ${VISUAL:-${EDITOR:-vi}} .editmsg || exit
+    else
+        echo "$message" > .editmsg
+    fi
 
     grep -v '^#' < .editmsg | git-stripspace > .tagmsg
 
Next: Chris Wright
Message 1 of 2 in “git tag can't take piped input?”
  1. Chris WrightAug 9, 2005
  2. git-tag-script tag message commandline optionChris Wright, Aug 10, 2005

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.