diff --git a/Annex/AdjustedBranch.hs b/Annex/AdjustedBranch.hs index a7b6f03ed7..c545930133 100644 --- a/Annex/AdjustedBranch.hs +++ b/Annex/AdjustedBranch.hs @@ -469,7 +469,7 @@ commitAdjustedTree' treesha (BasisBranch basis) parents = (commitCommitterMetaData basiscommit) (mkcommit cmode) mkcommit cmode = Git.Branch.commitTree cmode - adjustedBranchCommitMessage parents treesha + [adjustedBranchCommitMessage] parents treesha {- This message should never be changed. -} adjustedBranchCommitMessage :: String @@ -577,7 +577,7 @@ reverseAdjustedCommit commitparent adj (csha, basiscommit) origbranch (commitAuthorMetaData basiscommit) (commitCommitterMetaData basiscommit) $ Git.Branch.commitTree cmode - (commitMessage basiscommit) + [commitMessage basiscommit] [commitparent] treesha return (Right revadjcommit) diff --git a/Annex/AdjustedBranch/Merge.hs b/Annex/AdjustedBranch/Merge.hs index 26ab0e7e3e..904f4ee412 100644 --- a/Annex/AdjustedBranch/Merge.hs +++ b/Annex/AdjustedBranch/Merge.hs @@ -153,7 +153,8 @@ mergeToAdjustedBranch tomerge (origbranch, adj) mergeconfig canresolvemerge comm then do cmode <- annexCommitMode <$> Annex.getGitConfig c <- inRepo $ Git.Branch.commitTree cmode - ("Merged " ++ fromRef tomerge) [adjmergecommit] + ["Merged " ++ fromRef tomerge] + [adjmergecommit] (commitTree currentcommit) inRepo $ Git.Branch.update "updating adjusted branch" currbranch c propigateAdjustedCommits origbranch adj diff --git a/Annex/Branch.hs b/Annex/Branch.hs index 9b5365b456..bcc9ae114d 100644 --- a/Annex/Branch.hs +++ b/Annex/Branch.hs @@ -945,9 +945,9 @@ rememberTreeishLocked treeish graftpoint jl = do addedt <- inRepo $ Git.Tree.graftTree treeish graftpoint origtree cmode <- annexCommitMode <$> Annex.getGitConfig c <- inRepo $ Git.Branch.commitTree cmode - "graft" [branchref] addedt + ["graft"] [branchref] addedt c' <- inRepo $ Git.Branch.commitTree cmode - "graft cleanup" [c] origtree + ["graft cleanup"] [c] origtree inRepo $ Git.Branch.update' fullname c' -- The tree in c' is the same as the tree in branchref, -- and the index was updated to that above, so it's safe to diff --git a/Annex/Import.hs b/Annex/Import.hs index eaf41f4f79..2778740382 100644 --- a/Annex/Import.hs +++ b/Annex/Import.hs @@ -86,7 +86,7 @@ data ImportCommitConfig = ImportCommitConfig { importCommitTracking :: Maybe Sha -- ^ Current commit on the remote tracking branch. , importCommitMode :: Git.Branch.CommitMode - , importCommitMessage :: String + , importCommitMessages :: [String] } {- Buils a commit for an import from a special remote. @@ -251,7 +251,7 @@ buildImportCommit' remote importcommitconfig mtrackingcommit imported@(History t mkcommit parents tree = inRepo $ Git.Branch.commitTree (importCommitMode importcommitconfig) - (importCommitMessage importcommitconfig) + (importCommitMessages importcommitconfig) parents tree diff --git a/Annex/RemoteTrackingBranch.hs b/Annex/RemoteTrackingBranch.hs index ade303e02d..06591d0918 100644 --- a/Annex/RemoteTrackingBranch.hs +++ b/Annex/RemoteTrackingBranch.hs @@ -77,7 +77,7 @@ makeRemoteTrackingBranchMergeCommit' commitsha importedhistory treesha = do cmode <- annexCommitMode <$> Annex.getGitConfig inRepo $ Git.Branch.commitTree cmode - "remote tracking branch" + ["remote tracking branch"] [commitsha, importedhistory] treesha diff --git a/Annex/View.hs b/Annex/View.hs index b47e34564b..7372287380 100644 --- a/Annex/View.hs +++ b/Annex/View.hs @@ -577,7 +577,7 @@ updateView view madj = do cmode <- annexCommitMode <$> Annex.getGitConfig let msg = "updated " ++ fromRef (branchView view madj) let parent = catMaybes [oldcommit] - inRepo (Git.Branch.commitTree cmode msg parent newtree) + inRepo (Git.Branch.commitTree cmode [msg] parent newtree) else return Nothing {- Diff between currently checked out branch and staged changes, and diff --git a/CHANGELOG b/CHANGELOG index 83dfa02de9..3a4adca108 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,8 @@ git-annex (10.20240228) UNRELEASED; urgency=medium the same repository. * Windows: Fix escaping output to terminal when using old versions of MinTTY. + * sync, assist, import: Allow -m option to be specified multiple + times, to provide additional paragraphs for the commit message. -- Joey Hess Tue, 27 Feb 2024 13:07:10 -0400 diff --git a/Command/FilterBranch.hs b/Command/FilterBranch.hs index 10f03cccda..6c565c5d29 100644 --- a/Command/FilterBranch.hs +++ b/Command/FilterBranch.hs @@ -189,7 +189,7 @@ seek o = withOtherTmp $ \tmpdir -> do liftIO $ removeWhenExistsWith removeLink tmpindex cmode <- annexCommitMode <$> Annex.getGitConfig cmessage <- Annex.Branch.commitMessage - c <- inRepo $ Git.commitTree cmode cmessage [] t + c <- inRepo $ Git.commitTree cmode [cmessage] [] t liftIO $ putStrLn (fromRef c) where ww = WarnUnmatchLsFiles "filter-branch" diff --git a/Command/Import.hs b/Command/Import.hs index a37064eefc..f5483cc7d5 100644 --- a/Command/Import.hs +++ b/Command/Import.hs @@ -1,6 +1,6 @@ {- git-annex command - - - Copyright 2012-2021 Joey Hess + - Copyright 2012-2024 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -70,7 +70,7 @@ data ImportOptions , importToSubDir :: Maybe FilePath , importContent :: Bool , checkGitIgnoreOption :: CheckGitIgnore - , messageOption :: Maybe String + , messageOption :: [String] } optParser :: CmdParamsDesc -> Parser ImportOptions @@ -82,7 +82,7 @@ optParser desc = do ) dupmode <- fromMaybe Default <$> optional duplicateModeParser ic <- Command.Add.checkGitIgnoreSwitch - message <- optional (strOption + message <- many (strOption ( long "message" <> short 'm' <> metavar "MSG" <> help "commit message" )) @@ -322,8 +322,8 @@ verifyExisting key destfile (yes, no) = do verifyEnoughCopiesToDrop [] key Nothing needcopies mincopies [] preverified tocheck (const yes) no -seekRemote :: Remote -> Branch -> Maybe TopFilePath -> Bool -> CheckGitIgnore -> Maybe String -> CommandSeek -seekRemote remote branch msubdir importcontent ci mimportmessage = do +seekRemote :: Remote -> Branch -> Maybe TopFilePath -> Bool -> CheckGitIgnore -> [String] -> CommandSeek +seekRemote remote branch msubdir importcontent ci importmessages = do importtreeconfig <- case msubdir of Nothing -> return ImportTree Just subdir -> @@ -336,7 +336,7 @@ seekRemote remote branch msubdir importcontent ci mimportmessage = do trackingcommit <- fromtrackingbranch Git.Ref.sha cmode <- annexCommitMode <$> Annex.getGitConfig - let importcommitconfig = ImportCommitConfig trackingcommit cmode importmessage + let importcommitconfig = ImportCommitConfig trackingcommit cmode importmessages' let commitimport = commitRemote remote branch tb trackingcommit importtreeconfig importcommitconfig importabletvar <- liftIO $ newTVarIO Nothing @@ -353,9 +353,9 @@ seekRemote remote branch msubdir importcontent ci mimportmessage = do includeCommandAction $ commitimport imported where - importmessage = fromMaybe - ("import from " ++ Remote.name remote) - mimportmessage + importmessages' + | null importmessages = ["import from " ++ Remote.name remote] + | otherwise = importmessages tb = mkRemoteTrackingBranch remote branch diff --git a/Command/Sync.hs b/Command/Sync.hs index e222dd0874..5c4ba2ebe2 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -1,7 +1,7 @@ {- git-annex command - - Copyright 2011 Joachim Breitner - - Copyright 2011-2023 Joey Hess + - Copyright 2011-2024 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -105,7 +105,7 @@ data SyncOptions = SyncOptions , notOnlyAnnexOption :: Bool , commitOption :: Bool , noCommitOption :: Bool - , messageOption :: Maybe String + , messageOption :: [String] , pullOption :: Bool , pushOption :: Bool , contentOption :: Maybe Bool @@ -125,7 +125,7 @@ instance Default SyncOptions where , notOnlyAnnexOption = False , commitOption = False , noCommitOption = False - , messageOption = Nothing + , messageOption = [] , pullOption = False , pushOption = False , contentOption = Just False @@ -169,8 +169,8 @@ optParser mode desc = SyncOptions ( long "no-commit" <> help "avoid git commit" )) - <*> unlessmode [SyncMode, AssistMode] Nothing - (optional (strOption + <*> unlessmode [SyncMode, AssistMode] [] + (many (strOption ( long "message" <> short 'm' <> metavar "MSG" <> help "commit message" ))) @@ -402,17 +402,18 @@ syncRemotes' ps available = commit :: SyncOptions -> CommandStart commit o = stopUnless shouldcommit $ starting "commit" ai si $ do - commitmessage <- maybe commitMsg return (messageOption o) Annex.Branch.commit =<< Annex.Branch.commitMessage + mopts <- concatMap (\msg -> [Param "-m", Param msg]) + <$> if null (messageOption o) + then (:[]) <$> commitMsg + else pure (messageOption o) next $ do showOutput let cmode = Git.Branch.ManualCommit cquiet <- Git.Branch.CommitQuiet <$> commandProgressDisabled - void $ inRepo $ Git.Branch.commitCommand cmode cquiet - [ Param "-a" - , Param "-m" - , Param commitmessage - ] + void $ inRepo $ Git.Branch.commitCommand + cmode cquiet + ([ Param "-a" ] ++ mopts) return True where shouldcommit = notOnlyAnnex o <&&> @@ -426,7 +427,8 @@ commitMsg :: Annex String commitMsg = do u <- getUUID m <- uuidDescMap - return $ "git-annex in " ++ maybe "unknown" fromUUIDDesc (M.lookup u m) + return $ "git-annex in " + ++ maybe "unknown" fromUUIDDesc (M.lookup u m) mergeLocal :: [Git.Merge.MergeConfig] -> SyncOptions -> CurrBranch -> CommandStart mergeLocal mergeconfig o currbranch = stopUnless (notOnlyAnnex o) $ @@ -578,7 +580,7 @@ importRemote importcontent o remote currbranch let (branch, subdir) = splitRemoteAnnexTrackingBranchSubdir b if canImportKeys remote importcontent then do - Command.Import.seekRemote remote branch subdir importcontent (CheckGitIgnore True) Nothing + Command.Import.seekRemote remote branch subdir importcontent (CheckGitIgnore True) [] -- Importing generates a branch -- that is not initially connected -- to the current branch, so allow diff --git a/Git/Branch.hs b/Git/Branch.hs index f30e3572f2..40ddaf78d8 100644 --- a/Git/Branch.hs +++ b/Git/Branch.hs @@ -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 diff --git a/doc/git-annex-assist.mdwn b/doc/git-annex-assist.mdwn index f71e2a2815..bc843be1a9 100644 --- a/doc/git-annex-assist.mdwn +++ b/doc/git-annex-assist.mdwn @@ -34,6 +34,9 @@ files that it does not match will instead be added with `git add`. Use this option to specify a commit message. + If multiple -m options are given, their values are concatenated + as separate paragraphs. + * `--content-of=path` `-C path` Only add, pull, and push files in the given path. diff --git a/doc/git-annex-import.mdwn b/doc/git-annex-import.mdwn index b72fae5d5f..e78fa0ac14 100644 --- a/doc/git-annex-import.mdwn +++ b/doc/git-annex-import.mdwn @@ -107,6 +107,9 @@ the tree of files on the remote, even when importing into a subdirectory. Use this option to specify a commit message for the changes that have been made to the special remote since the last import from it. + If multiple -m options are given, their values are concatenated + as separate paragraphs. + # IMPORTING FROM A DIRECTORY When run with a path, `git annex import` **moves** files from somewhere outside diff --git a/doc/git-annex-sync.mdwn b/doc/git-annex-sync.mdwn index d3e76be91a..6c7235ddf7 100644 --- a/doc/git-annex-sync.mdwn +++ b/doc/git-annex-sync.mdwn @@ -51,6 +51,9 @@ when syncing with repositories that have preferred content configured. Use this option to specify a commit message. + If multiple -m options are given, their values are concatenated + as separate paragraphs. + * `--pull`, `--no-pull` Use this option to disable pulling. diff --git a/doc/todo/multiple_-m.mdwn b/doc/todo/multiple_-m.mdwn index c9c01b2ef9..14cb9189e3 100644 --- a/doc/todo/multiple_-m.mdwn +++ b/doc/todo/multiple_-m.mdwn @@ -1,2 +1,4 @@ git-annex sync etc -m should be able to be specified multiple times. In git commit, multiple -m can be used to make a multiparagraph commit. --[[Joey]] + +> [[done]]