aboutsummaryrefslogtreecommitdiff
path: root/git-tag.sh
diff options
context:
space:
mode:
authorAndy Parkins <andyparkins@gmail.com>2007-01-26 14:13:46 +0000
committerJunio C Hamano <junkio@cox.net>2007-01-27 13:46:59 -0800
commitd67778eccdf778f0fc252aaade8a47c23bfebbd6 (patch)
treef05502ba3cffa2a3c0d630a1739f0c6667be9d11 /git-tag.sh
parentf127404c45eff139037834a6464b68fbe1798e16 (diff)
downloadgit-d67778eccdf778f0fc252aaade8a47c23bfebbd6.tar.gz
git-d67778eccdf778f0fc252aaade8a47c23bfebbd6.tar.xz
Allow the tag signing key to be specified in the config file
I did this: $ git tag -s test-sign gpg: skipped "Andy Parkins <andyparkins@gmail.com>": secret key not available gpg: signing failed: secret key not available failed to sign the tag with GPG. The problem is that I have used the comment field in my key's UID definition. $ gpg --list-keys andy pub 1024D/4F712F6D 2003-08-14 uid Andy Parkins (Google) <andyparkins@gmail.com> So when git-tag looks for "Andy Parkins <andyparkins@gmail.com>"; obviously it's not going to be found. There shouldn't be a requirement that I use the same form of my name in my git repository and my gpg key - I might want to be formal (Andrew) in my gpg key and informal (Andy) in the repository. Further I might have multiple keys in my keyring, and might want to use one that doesn't match up with the address I use in commit messages. This patch adds a configuration entry "user.signingkey" which, if present, will be passed to the "-u" switch for gpg, allowing the tag signing key to be overridden. If the entry is not present, the fallback is the original method, which means existing behaviour will continue untouched. Signed-off-by: Andy Parkins <andyparkins@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-tag.sh')
-rwxr-xr-xgit-tag.sh6
1 files changed, 4 insertions, 2 deletions
diff --git a/git-tag.sh b/git-tag.sh
index 94499c9b3..988bf4c6a 100755
--- a/git-tag.sh
+++ b/git-tag.sh
@@ -112,7 +112,9 @@ git-check-ref-format "tags/$name" ||
object=$(git-rev-parse --verify --default HEAD "$@") || exit 1
type=$(git-cat-file -t $object) || exit 1
tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
-: ${username:=$(expr "z$tagger" : 'z\(.*>\)')}
+
+keyid=$(git-repo-config user.signingkey) ||
+ keyid=$(expr "z$tagger" : 'z\(.*>\)')
trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
@@ -139,7 +141,7 @@ if [ "$annotate" ]; then
cat "$GIT_DIR"/TAG_FINALMSG ) >"$GIT_DIR"/TAG_TMP
rm -f "$GIT_DIR"/TAG_TMP.asc "$GIT_DIR"/TAG_FINALMSG
if [ "$signed" ]; then
- gpg -bsa -u "$username" "$GIT_DIR"/TAG_TMP &&
+ gpg -bsa -u "$keyid" "$GIT_DIR"/TAG_TMP &&
cat "$GIT_DIR"/TAG_TMP.asc >>"$GIT_DIR"/TAG_TMP ||
die "failed to sign the tag with GPG."
fi