summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/hooks/git/dotfiles/post-checkout12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/hooks/git/dotfiles/post-checkout b/lib/hooks/git/dotfiles/post-checkout
index 24f733e7..109fe4cc 100755
--- a/lib/hooks/git/dotfiles/post-checkout
+++ b/lib/hooks/git/dotfiles/post-checkout
@@ -2,7 +2,17 @@
branch="$(git symbolic-ref --short HEAD)"
-if [ "$branch" = "master" ]; then
+# Check that signing is likely to succeed before setting
+# commit.gpgsign, by looking for presence of a secret key with the
+# signing capability.
+#
+# The reason this is needed is that this post-checkout hook will get
+# called during a rebase onto master, and I want to do that on hosts
+# which don't have access to my secret key. If commit.gpgsign gets
+# set to true on those hosts, the rebase will be interrupted
+if [ "$branch" = "master" ] \
+ && gpg --list-secret-keys $(git config user.signingKey) \
+ | grep -Eq '^(ssb|sec)[^#].*\[[A-Z]*S[A-Z]*\]$'; then
git config commit.gpgsign true
else
git config commit.gpgsign false