threads / discuss / 1457

git tag can't take piped input?

Subject: git tag can't take piped input?

## tl;dr

2 messages between Aug 9, 2005 and Aug 10, 2005.

replies: 1people: 1as markdown or json

Chris Wright· Aug 9, 2005, 00:04 UTC · lore

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
 
Chris Wright· Aug 10, 2005, 18:06 UTC · re: Chris Wright · lore

[PATCH] git-tag-script tag message commandline option

[resend more clearly identified as patch]

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

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
 

← back to recent threads