Added annex.allowsign option.
This commit was sponsored by Ilya Shlyakhter on Patreon.
This commit is contained in:
parent
02a8573bf2
commit
3b34d123ed
13 changed files with 97 additions and 32 deletions
|
@ -59,6 +59,7 @@ import Utility.Tmp.Dir
|
|||
import Utility.CopyFile
|
||||
import qualified Database.Keys
|
||||
import Config
|
||||
import Config.CommitMode
|
||||
|
||||
import qualified Data.Map as M
|
||||
|
||||
|
@ -224,8 +225,9 @@ adjustToCrippledFileSystem :: Annex ()
|
|||
adjustToCrippledFileSystem = do
|
||||
warning "Entering an adjusted branch where files are unlocked as this filesystem does not support locked files."
|
||||
checkVersionSupported
|
||||
whenM (isNothing <$> inRepo Git.Branch.current) $
|
||||
void $ inRepo $ Git.Branch.commitCommand Git.Branch.AutomaticCommit
|
||||
whenM (isNothing <$> inRepo Git.Branch.current) $ do
|
||||
cmode <- implicitCommitMode
|
||||
void $ inRepo $ Git.Branch.commitCommand cmode
|
||||
[ Param "--quiet"
|
||||
, Param "--allow-empty"
|
||||
, Param "-m"
|
||||
|
@ -310,12 +312,16 @@ commitAdjustedTree' :: Sha -> BasisBranch -> [Ref] -> Annex Sha
|
|||
commitAdjustedTree' treesha (BasisBranch basis) parents =
|
||||
go =<< catCommit basis
|
||||
where
|
||||
go Nothing = inRepo mkcommit
|
||||
go (Just basiscommit) = inRepo $ commitWithMetaData
|
||||
(commitAuthorMetaData basiscommit)
|
||||
(commitCommitterMetaData basiscommit)
|
||||
mkcommit
|
||||
mkcommit = Git.Branch.commitTree Git.Branch.AutomaticCommit
|
||||
go Nothing = do
|
||||
cmode <- implicitCommitMode
|
||||
inRepo $ mkcommit cmode
|
||||
go (Just basiscommit) = do
|
||||
cmode <- implicitCommitMode
|
||||
inRepo $ commitWithMetaData
|
||||
(commitAuthorMetaData basiscommit)
|
||||
(commitCommitterMetaData basiscommit)
|
||||
(mkcommit cmode)
|
||||
mkcommit cmode = Git.Branch.commitTree cmode
|
||||
adjustedBranchCommitMessage parents treesha
|
||||
|
||||
{- This message should never be changed. -}
|
||||
|
@ -444,7 +450,8 @@ mergeToAdjustedBranch tomerge (origbranch, adj) mergeconfig canresolvemerge comm
|
|||
reparent adjtree adjmergecommit (Just currentcommit) = do
|
||||
if (commitTree currentcommit /= adjtree)
|
||||
then do
|
||||
c <- inRepo $ Git.Branch.commitTree Git.Branch.AutomaticCommit
|
||||
cmode <- implicitCommitMode
|
||||
c <- inRepo $ Git.Branch.commitTree cmode
|
||||
("Merged " ++ fromRef tomerge) [adjmergecommit]
|
||||
(commitTree currentcommit)
|
||||
inRepo $ Git.Branch.update "updating adjusted branch" currbranch c
|
||||
|
@ -534,12 +541,14 @@ reverseAdjustedCommit commitparent adj (csha, basiscommit) origbranch
|
|||
| length (commitParent basiscommit) > 1 = return $
|
||||
Left $ "unable to propigate merge commit " ++ show csha ++ " back to " ++ show origbranch
|
||||
| otherwise = do
|
||||
cmode <- implicitCommitMode
|
||||
treesha <- reverseAdjustedTree commitparent adj csha
|
||||
revadjcommit <- inRepo $ commitWithMetaData
|
||||
(commitAuthorMetaData basiscommit)
|
||||
(commitCommitterMetaData basiscommit) $
|
||||
Git.Branch.commitTree Git.Branch.AutomaticCommit
|
||||
(commitMessage basiscommit) [commitparent] treesha
|
||||
Git.Branch.commitTree cmode
|
||||
(commitMessage basiscommit)
|
||||
[commitparent] treesha
|
||||
return (Right revadjcommit)
|
||||
|
||||
{- Adjusts the tree of the basis, changing only the files that the
|
||||
|
|
|
@ -70,6 +70,7 @@ import Annex.Branch.Transitions
|
|||
import qualified Annex
|
||||
import Annex.Hook
|
||||
import Utility.Directory.Stream
|
||||
import Config.CommitMode
|
||||
|
||||
{- Name of the branch that is used to store git-annex's information. -}
|
||||
name :: Git.Ref
|
||||
|
@ -109,8 +110,9 @@ getBranch = maybe (hasOrigin >>= go >>= use) return =<< branchsha
|
|||
[Param "branch", Param $ fromRef name, Param $ fromRef originname]
|
||||
fromMaybe (error $ "failed to create " ++ fromRef name)
|
||||
<$> branchsha
|
||||
go False = withIndex' True $
|
||||
inRepo $ Git.Branch.commitAlways Git.Branch.AutomaticCommit "branch created" fullname []
|
||||
go False = withIndex' True $ do
|
||||
cmode <- implicitCommitMode
|
||||
inRepo $ Git.Branch.commitAlways cmode "branch created" fullname []
|
||||
use sha = do
|
||||
setIndexSha sha
|
||||
return sha
|
||||
|
@ -317,7 +319,8 @@ commitIndex jl branchref message parents = do
|
|||
commitIndex' :: JournalLocked -> Git.Ref -> String -> String -> Integer -> [Git.Ref] -> Annex ()
|
||||
commitIndex' jl branchref message basemessage retrynum parents = do
|
||||
updateIndex jl branchref
|
||||
committedref <- inRepo $ Git.Branch.commitAlways Git.Branch.AutomaticCommit message fullname parents
|
||||
cmode <- implicitCommitMode
|
||||
committedref <- inRepo $ Git.Branch.commitAlways cmode message fullname parents
|
||||
setIndexSha committedref
|
||||
parentrefs <- commitparents <$> catObject committedref
|
||||
when (racedetected branchref parentrefs) $
|
||||
|
@ -551,7 +554,8 @@ performTransitionsLocked jl ts neednewlocalbranch transitionedrefs = do
|
|||
Annex.Queue.flush
|
||||
if neednewlocalbranch
|
||||
then do
|
||||
committedref <- inRepo $ Git.Branch.commitAlways Git.Branch.AutomaticCommit message fullname transitionedrefs
|
||||
cmode <- implicitCommitMode
|
||||
committedref <- inRepo $ Git.Branch.commitAlways cmode message fullname transitionedrefs
|
||||
setIndexSha committedref
|
||||
else do
|
||||
ref <- getBranch
|
||||
|
@ -657,9 +661,10 @@ rememberTreeish treeish graftpoint = lockJournal $ \jl -> do
|
|||
origtree <- fromMaybe (giveup "unable to determine git-annex branch tree") <$>
|
||||
inRepo (Git.Ref.tree branchref)
|
||||
addedt <- inRepo $ Git.Tree.graftTree treeish graftpoint origtree
|
||||
c <- inRepo $ Git.Branch.commitTree Git.Branch.AutomaticCommit
|
||||
cmode <- implicitCommitMode
|
||||
c <- inRepo $ Git.Branch.commitTree cmode
|
||||
"graft" [branchref] addedt
|
||||
c' <- inRepo $ Git.Branch.commitTree Git.Branch.AutomaticCommit
|
||||
c' <- inRepo $ Git.Branch.commitTree cmode
|
||||
"graft cleanup" [c] origtree
|
||||
inRepo $ Git.Branch.update' fullname c'
|
||||
-- The tree in c' is the same as the tree in branchref,
|
||||
|
|
|
@ -22,6 +22,7 @@ import qualified Git.Ref
|
|||
import qualified Git.Branch
|
||||
import Git.History
|
||||
import qualified Types.Remote as Remote
|
||||
import Config.CommitMode
|
||||
|
||||
import qualified Data.Set as S
|
||||
|
||||
|
@ -72,9 +73,10 @@ makeRemoteTrackingBranchMergeCommit tb commitsha =
|
|||
_ -> return commitsha
|
||||
|
||||
makeRemoteTrackingBranchMergeCommit' :: Sha -> Sha -> Sha -> Annex Sha
|
||||
makeRemoteTrackingBranchMergeCommit' commitsha importedhistory treesha =
|
||||
makeRemoteTrackingBranchMergeCommit' commitsha importedhistory treesha = do
|
||||
cmode <- implicitCommitMode
|
||||
inRepo $ Git.Branch.commitTree
|
||||
Git.Branch.AutomaticCommit
|
||||
cmode
|
||||
"remote tracking branch"
|
||||
[commitsha, importedhistory]
|
||||
treesha
|
||||
|
|
|
@ -30,6 +30,7 @@ import Logs.View
|
|||
import Utility.Glob
|
||||
import Types.Command
|
||||
import CmdLine.Action
|
||||
import Config.CommitMode
|
||||
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.ByteString as B
|
||||
|
@ -418,7 +419,8 @@ withViewIndex a = do
|
|||
genViewBranch :: View -> Annex Git.Branch
|
||||
genViewBranch view = withViewIndex $ do
|
||||
let branch = branchView view
|
||||
void $ inRepo $ Git.Branch.commit Git.Branch.AutomaticCommit True (fromRef branch) branch []
|
||||
cmode <- implicitCommitMode
|
||||
void $ inRepo $ Git.Branch.commit cmode True (fromRef branch) branch []
|
||||
return branch
|
||||
|
||||
withCurrentView :: (View -> Annex a) -> Annex a
|
||||
|
|
|
@ -22,6 +22,7 @@ import Logs.PreferredContent
|
|||
import qualified Annex.Branch
|
||||
import Utility.Process.Transcript
|
||||
import Config
|
||||
import Config.CommitMode
|
||||
|
||||
{- Makes a new git repository. Or, if a git repository already
|
||||
- exists, returns False. -}
|
||||
|
@ -53,8 +54,9 @@ initRepo True primary_assistant_repo dir desc mgroup = inDir dir $ do
|
|||
initRepo' desc mgroup
|
||||
{- Initialize the master branch, so things that expect
|
||||
- to have it will work, before any files are added. -}
|
||||
unlessM (Git.Config.isBare <$> gitRepo) $
|
||||
void $ inRepo $ Git.Branch.commitCommand Git.Branch.AutomaticCommit
|
||||
unlessM (Git.Config.isBare <$> gitRepo) $ do
|
||||
cmode <- implicitCommitMode
|
||||
void $ inRepo $ Git.Branch.commitCommand cmode
|
||||
[ Param "--quiet"
|
||||
, Param "--allow-empty"
|
||||
, Param "-m"
|
||||
|
|
|
@ -36,9 +36,9 @@ import qualified Annex
|
|||
import Utility.InodeCache
|
||||
import qualified Database.Keys
|
||||
import qualified Command.Sync
|
||||
import qualified Git.Branch
|
||||
import Utility.Tuple
|
||||
import Utility.Metered
|
||||
import Config.CommitMode
|
||||
|
||||
import Data.Time.Clock
|
||||
import qualified Data.Set as S
|
||||
|
@ -231,7 +231,8 @@ commitStaged msg = do
|
|||
case v of
|
||||
Left _ -> return False
|
||||
Right _ -> do
|
||||
ok <- Command.Sync.commitStaged Git.Branch.AutomaticCommit msg
|
||||
cmode <- implicitCommitMode
|
||||
ok <- Command.Sync.commitStaged cmode msg
|
||||
when ok $
|
||||
Command.Sync.updateBranches =<< getCurrentBranch
|
||||
return ok
|
||||
|
|
|
@ -19,6 +19,7 @@ import qualified Git
|
|||
import qualified Git.Branch
|
||||
import qualified Git.Ref
|
||||
import qualified Command.Sync
|
||||
import Config.CommitMode
|
||||
|
||||
{- This thread watches for changes to .git/refs/, and handles incoming
|
||||
- pushes. -}
|
||||
|
@ -80,11 +81,13 @@ onChange file
|
|||
[ "merging", Git.fromRef changedbranch
|
||||
, "into", Git.fromRef b
|
||||
]
|
||||
void $ liftAnnex $ Command.Sync.merge
|
||||
currbranch Command.Sync.mergeConfig
|
||||
def
|
||||
Git.Branch.AutomaticCommit
|
||||
changedbranch
|
||||
void $ liftAnnex $ do
|
||||
cmode <- implicitCommitMode
|
||||
Command.Sync.merge
|
||||
currbranch Command.Sync.mergeConfig
|
||||
def
|
||||
cmode
|
||||
changedbranch
|
||||
mergecurrent' _ = noop
|
||||
|
||||
{- Is the first branch a synced branch or remote tracking branch related
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
git-annex (7.20191107) UNRELEASED; urgency=medium
|
||||
|
||||
* Added annex.allowsign option.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Mon, 11 Nov 2019 15:59:47 -0400
|
||||
|
||||
git-annex (7.20191106) upstream; urgency=medium
|
||||
|
||||
* init: Fix bug that lost modifications to unlocked files when init is
|
||||
|
|
|
@ -30,9 +30,9 @@ import Utility.InodeCache
|
|||
import Logs.Location
|
||||
import Git.FilePath
|
||||
import Git.Types
|
||||
import Git.Branch
|
||||
import Types.Import
|
||||
import Utility.Metered
|
||||
import Config.CommitMode
|
||||
|
||||
import Control.Concurrent.STM
|
||||
|
||||
|
@ -266,7 +266,8 @@ seekRemote remote branch msubdir = do
|
|||
Nothing -> giveup $ "Unable to find base tree for branch " ++ fromRef branch
|
||||
|
||||
trackingcommit <- fromtrackingbranch Git.Ref.sha
|
||||
let importcommitconfig = ImportCommitConfig trackingcommit AutomaticCommit importmessage
|
||||
cmode <- implicitCommitMode
|
||||
let importcommitconfig = ImportCommitConfig trackingcommit cmode importmessage
|
||||
let commitimport = commitRemote remote branch tb trackingcommit importtreeconfig importcommitconfig
|
||||
|
||||
importabletvar <- liftIO $ newTVarIO Nothing
|
||||
|
|
18
Config/CommitMode.hs
Normal file
18
Config/CommitMode.hs
Normal file
|
@ -0,0 +1,18 @@
|
|||
{- git-annex configuration
|
||||
-
|
||||
- Copyright 2019 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Config.CommitMode where
|
||||
|
||||
import Annex.Common
|
||||
import qualified Annex
|
||||
import Git.Branch (CommitMode(..))
|
||||
|
||||
implicitCommitMode :: Annex CommitMode
|
||||
implicitCommitMode = go . annexAllowSign <$> Annex.getGitConfig
|
||||
where
|
||||
go True = ManualCommit
|
||||
go False = AutomaticCommit
|
|
@ -1,6 +1,6 @@
|
|||
{- git-annex configuration
|
||||
-
|
||||
- Copyright 2012-2015 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2012-2019 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -105,6 +105,7 @@ data GitConfig = GitConfig
|
|||
, annexJobs :: Concurrency
|
||||
, annexCacheCreds :: Bool
|
||||
, annexAutoUpgradeRepository :: Bool
|
||||
, annexAllowSign :: Bool
|
||||
, coreSymlinks :: Bool
|
||||
, coreSharedRepository :: SharedRepository
|
||||
, receiveDenyCurrentBranch :: DenyCurrentBranch
|
||||
|
@ -186,6 +187,7 @@ extractGitConfig r = GitConfig
|
|||
parseConcurrency =<< getmaybe (annex "jobs")
|
||||
, annexCacheCreds = getbool (annex "cachecreds") True
|
||||
, annexAutoUpgradeRepository = getbool (annex "autoupgraderepository") True
|
||||
, annexAllowSign = getbool (annex "allowsign") False
|
||||
, coreSymlinks = getbool "core.symlinks" True
|
||||
, coreSharedRepository = getSharedRepository r
|
||||
, receiveDenyCurrentBranch = getDenyCurrentBranch r
|
||||
|
|
|
@ -1028,6 +1028,19 @@ Like other git commands, git-annex is configured via `.git/config`.
|
|||
This works well in combination with annex.alwayscommit=false,
|
||||
to gather up a set of changes and commit them with a message you specify.
|
||||
|
||||
* `annex.allowsign`
|
||||
|
||||
By default git-annex avoids gpg signing commits that it makes when
|
||||
they're not the purpose of a command, but only a side effect.
|
||||
That default avoids lots of gpg password prompts when
|
||||
commit.gpgSign is set. A command like `git annex sync` or `git annex merge`
|
||||
will gpg sign its commit, but a command like `git annex get`,
|
||||
that updates the git-annex branch, will not. The assistant also avoids
|
||||
signing commits.
|
||||
|
||||
Setting annex.allowsign to true lets all commits be signed, as
|
||||
controlled by commit.gpgSign and other git configuration.
|
||||
|
||||
* `annex.merge-annex-branches`
|
||||
|
||||
By default, git-annex branches that have been pulled from remotes
|
||||
|
|
|
@ -806,6 +806,7 @@ Executable git-annex
|
|||
Command.Whereis
|
||||
Common
|
||||
Config
|
||||
Config.CommitMode
|
||||
Config.Cost
|
||||
Config.Files
|
||||
Config.DynamicConfig
|
||||
|
|
Loading…
Reference in a new issue