Skip to content

Commit c882bc9

Browse files
Chris WrightJunio C Hamano
authored andcommitted
[PATCH] Add -m <message> option to "git tag"
Allow users to create a tag message by passing message on command line instead of requiring an $EDITOR session. Signed-off-by: Chris Wright <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent adee7bd commit c882bc9

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

git-tag-script

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
. git-sh-setup-script || die "Not a git archive"
55

66
usage () {
7-
echo >&2 "Usage: git-tag-script [-a | -s] [-f] tagname"
7+
echo >&2 "Usage: git-tag-script [-a | -s] [-f] [-m "tag message"] tagname"
88
exit 1
99
}
1010

1111
annotate=
1212
signed=
1313
force=
14+
message=
1415
while case "$#" in 0) break ;; esac
1516
do
1617
case "$1" in
@@ -24,6 +25,11 @@ do
2425
-f)
2526
force=1
2627
;;
28+
-m)
29+
annotate=1
30+
shift
31+
message="$1"
32+
;;
2733
-*)
2834
usage
2935
;;
@@ -48,10 +54,14 @@ tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
4854
trap 'rm -f .tmp-tag* .tagmsg .editmsg' 0
4955

5056
if [ "$annotate" ]; then
51-
( echo "#"
52-
echo "# Write a tag message"
53-
echo "#" ) > .editmsg
54-
${VISUAL:-${EDITOR:-vi}} .editmsg || exit
57+
if [ -z "$message" ]; then
58+
( echo "#"
59+
echo "# Write a tag message"
60+
echo "#" ) > .editmsg
61+
${VISUAL:-${EDITOR:-vi}} .editmsg || exit
62+
else
63+
echo "$message" > .editmsg
64+
fi
5565

5666
grep -v '^#' < .editmsg | git-stripspace > .tagmsg
5767

0 commit comments

Comments
 (0)