Avoid using git commit in direct mode, since in some situations it will read the full contents of files in the tree.
The assistant's commit code also always avoids git commit, for simplicity. Indirect mode sync still does a git commit -a to catch unstaged changes. Note that this means that direct mode sync no longer runs the pre-commit hook or any other hooks git commit might call. The git annex pre-commit hook action for direct mode is however explicitly run. (The assistant already ran git commit with hooks disabled, so no change there.)
This commit is contained in:
parent
4f4dba50cb
commit
03932212ec
9 changed files with 95 additions and 73 deletions
|
@ -103,19 +103,33 @@ syncRemotes rs = ifM (Annex.getState Annex.fast) ( nub <$> pickfast , wanted )
|
|||
commit :: CommandStart
|
||||
commit = next $ next $ ifM isDirect
|
||||
( do
|
||||
void stageDirect
|
||||
runcommit []
|
||||
, runcommit [Param "-a"]
|
||||
)
|
||||
where
|
||||
runcommit ps = do
|
||||
showStart "commit" ""
|
||||
showOutput
|
||||
void stageDirect
|
||||
void preCommitDirect
|
||||
commitStaged commitmessage
|
||||
, do
|
||||
showStart "commit" ""
|
||||
Annex.Branch.commit "update"
|
||||
-- Commit will fail when the tree is clean, so ignore failure.
|
||||
let params = Param "commit" : ps ++
|
||||
[Param "-m", Param "git-annex automatic sync"]
|
||||
_ <- inRepo $ tryIO . Git.Command.runQuiet params
|
||||
_ <- inRepo $ tryIO . Git.Command.runQuiet
|
||||
[ Param "commit"
|
||||
, Param "-a"
|
||||
, Param "-m"
|
||||
, Param commitmessage
|
||||
]
|
||||
return True
|
||||
)
|
||||
where
|
||||
commitmessage = "git-annex automatic sync"
|
||||
|
||||
commitStaged :: String -> Annex Bool
|
||||
commitStaged commitmessage = go =<< inRepo Git.Branch.currentUnsafe
|
||||
where
|
||||
go Nothing = return False
|
||||
go (Just branch) = do
|
||||
parent <- inRepo $ Git.Ref.sha branch
|
||||
void $ inRepo $ Git.Branch.commit False commitmessage branch
|
||||
(maybe [] (:[]) parent)
|
||||
return True
|
||||
|
||||
mergeLocal :: Maybe Git.Ref -> CommandStart
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue