git-tag: Do not assume the working tree root is writable.
This is a long overdue companion commit that fixed git-commit (Santi's f8e2c54c9a17af3319e96db1d9e97ace36ae6831). Having the temporary files in the working tree root when making tags is not as bad because it does not involve 'git status' as the git-commit case, but this makes things more consistent. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Nov 3, 2005 at 15:26 UTC
a10aad6a9a37fbafcda590a00ddaf7b2bfda940e
1 file changed
+13
-11
git-tag.sh
+13
-11
@@ -61,33 +61,35 @@ type=$(git-cat-file -t $object) || exit 1
61
tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
62
: ${username:=$(expr "$tagger" : '\(.*>\)')}
63
64
-trap 'rm -f .tmp-tag* .tagmsg .editmsg' 0
64
+trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
65
66
if [ "$annotate" ]; then
67
if [ -z "$message" ]; then
68
( echo "#"
69
echo "# Write a tag message"
70
- echo "#" ) > .editmsg
71
- ${VISUAL:-${EDITOR:-vi}} .editmsg || exit
70
+ echo "#" ) > "$GIT_DIR"/TAG_EDITMSG
71
+ ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR"/TAG_EDITMSG || exit
72
else
73
- echo "$message" > .editmsg
73
+ echo "$message" >"$GIT_DIR"/TAG_EDITMSG
74
fi
75
76
- grep -v '^#' < .editmsg | git-stripspace > .tagmsg
76
+ grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG |
77
+ git-stripspace >"$GIT_DIR"/TAG_FINALMSG
78
78
- [ -s .tagmsg ] || {
79
+ [ -s "$GIT_DIR"/TAG_FINALMSG ] || {
80
echo >&2 "No tag message?"
81
exit 1
82
}
83
83
- ( echo -e "object $object\ntype $type\ntag $name\ntagger $tagger\n"; cat .tagmsg ) > .tmp-tag
84
- rm -f .tmp-tag.asc .tagmsg
84
+ ( echo -e "object $object\ntype $type\ntag $name\ntagger $tagger\n";
85
+ cat "$GIT_DIR"/TAG_FINALMSG ) >"$GIT_DIR"/TAG_TMP
86
+ rm -f "$GIT_DIR"/TAG_TMP.asc "$GIT_DIR"/TAG_FINALMSG
87
if [ "$signed" ]; then
86
- gpg -bsa -u "$username" .tmp-tag &&
87
- cat .tmp-tag.asc >>.tmp-tag ||
88
+ gpg -bsa -u "$username" "$GIT_DIR"/TAG_TMP &&
89
+ cat "$GIT_DIR"/TAG_TMP.asc >>"$GIT_DIR"/TAG_TMP ||
90
die "failed to sign the tag with GPG."
91
fi
90
- object=$(git-mktag < .tmp-tag)
92
+ object=$(git-mktag < "$GIT_DIR"/TAG_TMP)
93
fi
94
95
mkdir -p "$GIT_DIR/refs/tags"