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.
This commit is contained in:
parent
155b221e51
commit
02a20288ef
3 changed files with 23 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -8,3 +8,5 @@ and pass -S to commit-tree.
|
|||
be done without version checks.)
|
||||
|
||||
--[[Joey]]
|
||||
|
||||
> [[done]] --[[Joey]]
|
||||
|
|
Loading…
Reference in a new issue