add createMessage

init: When annex.commitmessage is set, use that message for the commit
that creates the git-annex branch.

This will be used by filter-branch too, and it seems to make sense to let
annex.commitmessage affect it.
This commit is contained in:
Joey Hess 2021-05-17 13:07:47 -04:00
parent 1da9fe5bd8
commit 8b6dad11a2
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 9 additions and 1 deletions

View file

@ -24,6 +24,7 @@ module Annex.Branch (
change, change,
maybeChange, maybeChange,
commitMessage, commitMessage,
createMessage,
commit, commit,
forceCommit, forceCommit,
getBranch, getBranch,
@ -129,7 +130,8 @@ getBranch = maybe (hasOrigin >>= go >>= use) return =<< branchsha
<$> branchsha <$> branchsha
go False = withIndex' True $ do go False = withIndex' True $ do
cmode <- annexCommitMode <$> Annex.getGitConfig cmode <- annexCommitMode <$> Annex.getGitConfig
inRepo $ Git.Branch.commitAlways cmode "branch created" fullname [] cmessage <- createMessage
inRepo $ Git.Branch.commitAlways cmode cmessage fullname []
use sha = do use sha = do
setIndexSha sha setIndexSha sha
return sha return sha
@ -363,6 +365,10 @@ set jl ru f c = do
commitMessage :: Annex String commitMessage :: Annex String
commitMessage = fromMaybe "update" . annexCommitMessage <$> Annex.getGitConfig commitMessage = fromMaybe "update" . annexCommitMessage <$> Annex.getGitConfig
{- Commit message used when creating the branch. -}
createMessage :: Annex String
createMessage = fromMaybe "branch created" . annexCommitMessage <$> Annex.getGitConfig
{- Stages the journal, and commits staged changes to the branch. -} {- Stages the journal, and commits staged changes to the branch. -}
commit :: String -> Annex () commit :: String -> Annex ()
commit = whenM (journalDirty gitAnnexJournalDir) . forceCommit commit = whenM (journalDirty gitAnnexJournalDir) . forceCommit

View file

@ -11,6 +11,8 @@ git-annex (8.20210429) UNRELEASED; urgency=medium
* reinject: Error out when run on a file that is not annexed, rather * reinject: Error out when run on a file that is not annexed, rather
than silently skipping it. than silently skipping it.
* assistant: Fix a crash on startup by avoiding using forkProcess. * assistant: Fix a crash on startup by avoiding using forkProcess.
* init: When annex.commitmessage is set, use that message for the commit
that creates the git-annex branch.
-- Joey Hess <id@joeyh.name> Mon, 03 May 2021 10:33:10 -0400 -- Joey Hess <id@joeyh.name> Mon, 03 May 2021 10:33:10 -0400