summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG3
-rw-r--r--Git/Branch.hs21
-rw-r--r--doc/todo/pass_-S_to_commit-tree.mdwn2
3 files changed, 23 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index fc6720928..3c42074f1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,9 @@ git-annex (6.20160528) UNRELEASED; urgency=medium
* sync --content: Fix bug that caused transfers of files to be made
to a git remote that does not have a UUID. This particularly impacted
clones from gcrypt repositories.
+ * Pass -S to git commit-tree when commit.gpgsign is set and when
+ making a non-automatic commit, in order to preserve current behavior
+ when used with git 1.9, which has stopped doing this itself.
-- Joey Hess <id@joeyh.name> Fri, 27 May 2016 13:12:48 -0400
diff --git a/Git/Branch.hs b/Git/Branch.hs
index 8f79f59b6..875f20f89 100644
--- a/Git/Branch.hs
+++ b/Git/Branch.hs
@@ -13,6 +13,7 @@ import Common
import Git
import Git.Sha
import Git.Command
+import qualified Git.Config
import qualified Git.Ref
import qualified Git.BuildVersion
@@ -114,19 +115,33 @@ fastForward branch (first:rest) repo =
(False, True) -> findbest c rs -- worse
(False, False) -> findbest c rs -- same
-{- The user may have set commit.gpgsign, indending all their manual
+{- The user may have set commit.gpgsign, intending all their manual
- commits to be signed. But signing automatic/background commits could
- easily lead to unwanted gpg prompts or failures.
-}
data CommitMode = ManualCommit | AutomaticCommit
deriving (Eq)
+{- Prevent signing automatic commits. -}
applyCommitMode :: CommitMode -> [CommandParam] -> [CommandParam]
applyCommitMode commitmode ps
| commitmode == AutomaticCommit && not (Git.BuildVersion.older "2.0.0") =
Param "--no-gpg-sign" : ps
| otherwise = ps
+{- Some versions of git commit-tree honor commit.gpgsign themselves,
+ - but others need -S to be passed to enable gpg signing of manual commits. -}
+applyCommitModeForCommitTree :: CommitMode -> [CommandParam] -> Repo -> [CommandParam]
+applyCommitModeForCommitTree commitmode ps r
+ | commitmode == ManualCommit =
+ case (Git.Config.getMaybe "commit.gpgsign" r) of
+ Just s | Git.Config.isTrue s == Just True ->
+ Param "-S":ps
+ _ -> ps'
+ | otherwise = ps'
+ where
+ ps' = applyCommitMode commitmode ps
+
{- Commit via the usual git command. -}
commitCommand :: CommitMode -> [CommandParam] -> Repo -> IO Bool
commitCommand = commitCommand' runBool
@@ -172,9 +187,9 @@ commitTree commitmode message parentrefs tree repo =
pipeWriteRead ([Param "commit-tree", Param (fromRef tree)] ++ ps)
sendmsg repo
where
- ps = applyCommitMode commitmode $
- map Param $ concatMap (\r -> ["-p", fromRef r]) parentrefs
sendmsg = Just $ flip hPutStr message
+ ps = applyCommitModeForCommitTree commitmode parentparams repo
+ parentparams = map Param $ concatMap (\r -> ["-p", fromRef r]) parentrefs
{- A leading + makes git-push force pushing a branch. -}
forcePush :: String -> String
diff --git a/doc/todo/pass_-S_to_commit-tree.mdwn b/doc/todo/pass_-S_to_commit-tree.mdwn
index ee6ff2d58..ecd7dc70e 100644
--- a/doc/todo/pass_-S_to_commit-tree.mdwn
+++ b/doc/todo/pass_-S_to_commit-tree.mdwn
@@ -8,3 +8,5 @@ and pass -S to commit-tree.
be done without version checks.)
--[[Joey]]
+
+> [[done]] --[[Joey]]