pre-commit: Avoid committing the git-annex branch
Except when a commit is made in a view, which changes metadata. Make the assistant commit the git-annex branch after git commit of working tree changes. This allows using the annex.commitmessage-command in the assistant to generate a commit message for the git-annex branch that relies on state gathered during the commit of the working tree. Eg, it might reuse the commit message. Note that, when not using the assistant, a git-annex add still commits the git-annex branch, so such a annex.commitmessage-command set up would not work then. But if someone is using the assistant and wants programmatic control over commit messages, this is useful. Someone not using the assistant can get the same result by using annex.alwayscommit=false during the git-annex add, and git-annex merge after they git commit. pre-commit was never really intended to commit the git-annex branch (except after recording changed metadata), but the assistant did sort of rely on it. It does later commit the git-annex branch before pushing to remotes, but I didn't want to risk building up lots of uncommitted changes to it if that didn't happen frequently. Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
This commit is contained in:
parent
68e99513f0
commit
3475b09c3e
5 changed files with 52 additions and 17 deletions
|
@ -1,6 +1,6 @@
|
|||
{- git-annex assistant commit thread
|
||||
-
|
||||
- Copyright 2012-2023 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2012-2024 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -19,7 +19,6 @@ import Assistant.TransferQueue
|
|||
import Assistant.Drop
|
||||
import Types.Transfer
|
||||
import Logs.Location
|
||||
import qualified Annex.Queue
|
||||
import Utility.ThreadScheduler
|
||||
import qualified Utility.Lsof as Lsof
|
||||
import qualified Utility.DirWatcher as DirWatcher
|
||||
|
@ -35,6 +34,8 @@ import Annex.InodeSentinal
|
|||
import Annex.CurrentBranch
|
||||
import Annex.FileMatcher
|
||||
import qualified Annex
|
||||
import qualified Annex.Queue
|
||||
import qualified Annex.Branch
|
||||
import Utility.InodeCache
|
||||
import qualified Database.Keys
|
||||
import qualified Command.Sync
|
||||
|
@ -248,6 +249,11 @@ commitStaged msg = do
|
|||
]
|
||||
when ok $
|
||||
Command.Sync.updateBranches =<< getCurrentBranch
|
||||
{- Commit the git-annex branch. This comes after
|
||||
- the commit of the staged changes, so that
|
||||
- annex.commitmessage-command can examine that
|
||||
- commit. -}
|
||||
Annex.Branch.commit =<< Annex.Branch.commitMessage
|
||||
return ok
|
||||
|
||||
{- If there are PendingAddChanges, or InProcessAddChanges, the files
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue