diff options
author | Joey Hess <joey@kitenet.net> | 2014-07-04 11:36:59 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-07-04 11:53:51 -0400 |
commit | dafe3950f721ce80d9fa8696daed626a071dab01 (patch) | |
tree | b3bb6eb22628506b356932793daa27a021429d4b /Annex | |
parent | 25e715f48fb1f4caecbcf36f5ea2ff55ecf6c3a9 (diff) |
support commit.gpgsign
Support users who have set commit.gpgsign, by disabling gpg signatures for
git-annex branch commits and commits made by the assistant.
The thinking here is that a user sets commit.gpgsign intending the commits
that they manually initiate to be gpg signed. But not commits made in the
background, whether by a deamon or implicitly to the git-annex branch.
gpg signing those would be at best a waste of CPU and at worst would fail,
or flood the user with gpg passphrase prompts, or put their signature on
changes they did not directly do.
See Debian bug #753720.
Also makes all commits done by git-annex go through a few central control
points, to make such changes easier in future.
Also disables commit.gpgsign in the test suite.
This commit was sponsored by Antoine Boegli.
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/AutoMerge.hs | 19 | ||||
-rw-r--r-- | Annex/Branch.hs | 6 | ||||
-rw-r--r-- | Annex/Direct.hs | 20 | ||||
-rw-r--r-- | Annex/MakeRepo.hs | 6 | ||||
-rw-r--r-- | Annex/View.hs | 2 |
5 files changed, 26 insertions, 27 deletions
diff --git a/Annex/AutoMerge.hs b/Annex/AutoMerge.hs index 71b28c1d4..cc27f6b28 100644 --- a/Annex/AutoMerge.hs +++ b/Annex/AutoMerge.hs @@ -12,12 +12,12 @@ import qualified Annex.Queue import Annex.Direct import Annex.CatFile import Annex.Link -import qualified Git.Command import qualified Git.LsFiles as LsFiles import qualified Git.UpdateIndex as UpdateIndex import qualified Git.Merge import qualified Git.Ref import qualified Git +import qualified Git.Branch import Git.Types (BlobType(..)) import Config import Annex.ReplaceFile @@ -29,17 +29,17 @@ import qualified Data.Set as S {- Merges from a branch into the current branch - (which may not exist yet), - with automatic merge conflict resolution. -} -autoMergeFrom :: Git.Ref -> (Maybe Git.Ref) -> Annex Bool -autoMergeFrom branch currbranch = do +autoMergeFrom :: Git.Ref -> (Maybe Git.Ref) -> Git.Branch.CommitMode -> Annex Bool +autoMergeFrom branch currbranch commitmode = do showOutput case currbranch of Nothing -> go Nothing Just b -> go =<< inRepo (Git.Ref.sha b) where go old = ifM isDirect - ( mergeDirect currbranch old branch (resolveMerge old branch) - , inRepo (Git.Merge.mergeNonInteractive branch) - <||> (resolveMerge old branch <&&> commitResolvedMerge) + ( mergeDirect currbranch old branch (resolveMerge old branch) commitmode + , inRepo (Git.Merge.mergeNonInteractive branch commitmode) + <||> (resolveMerge old branch <&&> commitResolvedMerge commitmode) ) {- Resolves a conflicted merge. It's important that any conflicts be @@ -166,10 +166,9 @@ cleanConflictCruft resolvedfs top = do matchesresolved f = S.member (base f) s base f = reverse $ drop 1 $ dropWhile (/= '~') $ reverse f -commitResolvedMerge :: Annex Bool -commitResolvedMerge = inRepo $ Git.Command.runBool - [ Param "commit" - , Param "--no-verify" +commitResolvedMerge :: Git.Branch.CommitMode -> Annex Bool +commitResolvedMerge commitmode = inRepo $ Git.Branch.commitCommand commitmode + [ Param "--no-verify" , Param "-m" , Param "git-annex automatic merge conflict fix" ] diff --git a/Annex/Branch.hs b/Annex/Branch.hs index 108f97b14..3443730d2 100644 --- a/Annex/Branch.hs +++ b/Annex/Branch.hs @@ -92,7 +92,7 @@ getBranch = maybe (hasOrigin >>= go >>= use) return =<< branchsha fromMaybe (error $ "failed to create " ++ fromRef name) <$> branchsha go False = withIndex' True $ - inRepo $ Git.Branch.commitAlways "branch created" fullname [] + inRepo $ Git.Branch.commitAlways Git.Branch.AutomaticCommit "branch created" fullname [] use sha = do setIndexSha sha return sha @@ -252,7 +252,7 @@ commitIndex jl branchref message parents = do commitIndex' :: JournalLocked -> Git.Ref -> String -> [Git.Ref] -> Annex () commitIndex' jl branchref message parents = do updateIndex jl branchref - committedref <- inRepo $ Git.Branch.commitAlways message fullname parents + committedref <- inRepo $ Git.Branch.commitAlways Git.Branch.AutomaticCommit message fullname parents setIndexSha committedref parentrefs <- commitparents <$> catObject committedref when (racedetected branchref parentrefs) $ @@ -471,7 +471,7 @@ performTransitionsLocked jl ts neednewlocalbranch transitionedrefs = do Annex.Queue.flush if neednewlocalbranch then do - committedref <- inRepo $ Git.Branch.commitAlways message fullname transitionedrefs + committedref <- inRepo $ Git.Branch.commitAlways Git.Branch.AutomaticCommit message fullname transitionedrefs setIndexSha committedref else do ref <- getBranch diff --git a/Annex/Direct.hs b/Annex/Direct.hs index 6e14c6b9b..356354aa9 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -151,8 +151,8 @@ addDirect file cache = do - Then the work tree is updated to reflect the merge, and - finally, the merge is committed and the real index updated. -} -mergeDirect :: Maybe Git.Ref -> Maybe Git.Ref -> Git.Branch -> Annex Bool -> Annex Bool -mergeDirect startbranch oldref branch resolvemerge = do +mergeDirect :: Maybe Git.Ref -> Maybe Git.Ref -> Git.Branch -> Annex Bool -> Git.Branch.CommitMode -> Annex Bool +mergeDirect startbranch oldref branch resolvemerge commitmode = do -- Use the index lock file as the temp index file. -- This is actually what git does when updating the index, -- and so it will prevent other git processes from making @@ -168,19 +168,19 @@ mergeDirect startbranch oldref branch resolvemerge = do createDirectoryIfMissing True d withIndexFile tmpi $ do - merged <- stageMerge d branch + merged <- stageMerge d branch commitmode r <- if merged then return True else resolvemerge mergeDirectCleanup d (fromMaybe Git.Sha.emptyTree oldref) - mergeDirectCommit merged startbranch branch + mergeDirectCommit merged startbranch branch commitmode liftIO $ rename tmpi reali return r {- Stage a merge into the index, avoiding changing HEAD or the current - branch. -} -stageMerge :: FilePath -> Git.Branch -> Annex Bool -stageMerge d branch = do +stageMerge :: FilePath -> Git.Branch -> Git.Branch.CommitMode -> Annex Bool +stageMerge d branch commitmode = do -- XXX A bug in git makes stageMerge unsafe to use if the git repo -- is configured with core.symlinks=false -- Using mergeNonInteractive is not ideal though, since it will @@ -190,7 +190,7 @@ stageMerge d branch = do -- <http://marc.info/?l=git&m=140262402204212&w=2> merger <- ifM (coreSymlinks <$> Annex.getGitConfig) ( return Git.Merge.stageMerge - , return Git.Merge.mergeNonInteractive + , return $ \ref -> Git.Merge.mergeNonInteractive ref commitmode ) inRepo $ \g -> merger branch $ g { location = Local { gitdir = Git.localGitDir g, worktree = Just d } } @@ -198,8 +198,8 @@ stageMerge d branch = do {- Commits after a direct mode merge is complete, and after the work - tree has been updated by mergeDirectCleanup. -} -mergeDirectCommit :: Bool -> Maybe Git.Ref -> Git.Branch -> Annex () -mergeDirectCommit allowff old branch = do +mergeDirectCommit :: Bool -> Maybe Git.Ref -> Git.Branch -> Git.Branch.CommitMode -> Annex () +mergeDirectCommit allowff old branch commitmode = do void preCommitDirect d <- fromRepo Git.localGitDir let merge_head = d </> "MERGE_HEAD" @@ -211,7 +211,7 @@ mergeDirectCommit allowff old branch = do msg <- liftIO $ catchDefaultIO ("merge " ++ fromRef branch) $ readFile merge_msg - void $ inRepo $ Git.Branch.commit False msg + void $ inRepo $ Git.Branch.commit commitmode False msg Git.Ref.headRef [Git.Ref.headRef, branch] ) liftIO $ mapM_ nukeFile [merge_head, merge_msg, merge_mode] diff --git a/Annex/MakeRepo.hs b/Annex/MakeRepo.hs index 695edd5f8..a1f797a76 100644 --- a/Annex/MakeRepo.hs +++ b/Annex/MakeRepo.hs @@ -12,6 +12,7 @@ import Annex.Init import qualified Git.Construct import qualified Git.Config import qualified Git.Command +import qualified Git.Branch import qualified Annex import Annex.UUID import Annex.Direct @@ -50,9 +51,8 @@ initRepo True primary_assistant_repo dir desc mgroup = inDir dir $ do {- 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.Command.runBool - [ Param "commit" - , Param "--quiet" + void $ inRepo $ Git.Branch.commitCommand Git.Branch.AutomaticCommit + [ Param "--quiet" , Param "--allow-empty" , Param "-m" , Param "created repository" diff --git a/Annex/View.hs b/Annex/View.hs index 5cf21cdfe..b96981612 100644 --- a/Annex/View.hs +++ b/Annex/View.hs @@ -433,7 +433,7 @@ genViewBranch :: View -> Annex () -> Annex Git.Branch genViewBranch view a = withIndex $ do a let branch = branchView view - void $ inRepo $ Git.Branch.commit True (fromRef branch) branch [] + void $ inRepo $ Git.Branch.commit Git.Branch.AutomaticCommit True (fromRef branch) branch [] return branch {- Runs an action using the view index file. |