multiple -m

sync, assist, import: Allow -m option to be specified multiple times, to
provide additional paragraphs for the commit message.

The option parser didn't allow multiple -m before, so there is no risk of
behavior change breaking something that was for some reason using multiple
-m already.

Pass through to git commands, so that the method used to assemble the
paragrahs is whatever git does. Which might conceivably change in the
future.

Note that git commit-tree has supported -m since git 1.7.7. commitTree
was probably not using it since it predates that version. Since the
configure script prevents building git-annex with git older than 2.1,
there is no risk that it's not supported now.

Sponsored-by: Nicholas Golder-Manning on Patreon
This commit is contained in:
Joey Hess 2024-03-27 15:58:27 -04:00
parent 377e9fff18
commit cee12f6a2f
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
15 changed files with 57 additions and 41 deletions

View file

@ -178,7 +178,7 @@ commit commitmode allowempty message branch parentrefs repo = do
tree <- writeTree repo
ifM (cancommit tree)
( do
sha <- commitTree commitmode message parentrefs tree repo
sha <- commitTree commitmode [message] parentrefs tree repo
update' branch sha repo
return $ Just sha
, return Nothing
@ -207,15 +207,15 @@ writeTreeQuiet repo = extractSha <$> withNullHandle go
go nullh = pipeReadStrict' (\p -> p { std_err = UseHandle nullh })
[Param "write-tree"] repo
commitTree :: CommitMode -> String -> [Ref] -> Ref -> Repo -> IO Sha
commitTree commitmode message parentrefs tree repo =
getSha "commit-tree" $
pipeWriteRead ([Param "commit-tree", Param (fromRef tree)] ++ ps)
sendmsg repo
commitTree :: CommitMode -> [String] -> [Ref] -> Ref -> Repo -> IO Sha
commitTree commitmode messages parentrefs tree repo =
getSha "commit-tree" $ pipeReadStrict ps repo
where
sendmsg = Just $ flip hPutStr message
ps = applyCommitModeForCommitTree commitmode parentparams repo
parentparams = map Param $ concatMap (\r -> ["-p", fromRef r]) parentrefs
ps = [Param "commit-tree", Param (fromRef tree)]
++ applyCommitModeForCommitTree commitmode baseparams repo
baseparams = map Param $
concatMap (\r -> ["-p", fromRef r]) parentrefs
++ concatMap (\msg -> ["-m", msg]) messages
{- A leading + makes git-push force pushing a branch. -}
forcePush :: String -> String