Revert "multiple -m"

This reverts commit cee12f6a2f.

This commit broke git-annex init run in a repo that was cloned from a
repo with an adjusted branch checked out.

The problem is that findAdjustingCommit was not able to identify the
commit that created the adjusted branch. It seems that there is an extra
"\n" at the end of the commit message that it does not expect.

Since backwards compatability needs to be maintained, cannot just make
findAdjustingCommit accept it with the "\n". Will have to instead
have one commitTree variant that uses the old method, and use it for
adjusted branch committing.
This commit is contained in:
Joey Hess 2024-04-02 17:29:07 -04:00
parent 2b0df3a76d
commit a8dd85ea5a
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
15 changed files with 41 additions and 57 deletions

View file

@ -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"

View file

@ -1,6 +1,6 @@
{- git-annex command
-
- Copyright 2012-2024 Joey Hess <id@joeyh.name>
- Copyright 2012-2021 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -70,7 +70,7 @@ data ImportOptions
, importToSubDir :: Maybe FilePath
, importContent :: Bool
, checkGitIgnoreOption :: CheckGitIgnore
, messageOption :: [String]
, messageOption :: Maybe String
}
optParser :: CmdParamsDesc -> Parser ImportOptions
@ -82,7 +82,7 @@ optParser desc = do
)
dupmode <- fromMaybe Default <$> optional duplicateModeParser
ic <- Command.Add.checkGitIgnoreSwitch
message <- many (strOption
message <- optional (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 -> [String] -> CommandSeek
seekRemote remote branch msubdir importcontent ci importmessages = do
seekRemote :: Remote -> Branch -> Maybe TopFilePath -> Bool -> CheckGitIgnore -> Maybe String -> CommandSeek
seekRemote remote branch msubdir importcontent ci mimportmessage = do
importtreeconfig <- case msubdir of
Nothing -> return ImportTree
Just subdir ->
@ -336,7 +336,7 @@ seekRemote remote branch msubdir importcontent ci importmessages = do
trackingcommit <- fromtrackingbranch Git.Ref.sha
cmode <- annexCommitMode <$> Annex.getGitConfig
let importcommitconfig = ImportCommitConfig trackingcommit cmode importmessages'
let importcommitconfig = ImportCommitConfig trackingcommit cmode importmessage
let commitimport = commitRemote remote branch tb trackingcommit importtreeconfig importcommitconfig
importabletvar <- liftIO $ newTVarIO Nothing
@ -353,9 +353,9 @@ seekRemote remote branch msubdir importcontent ci importmessages = do
includeCommandAction $
commitimport imported
where
importmessages'
| null importmessages = ["import from " ++ Remote.name remote]
| otherwise = importmessages
importmessage = fromMaybe
("import from " ++ Remote.name remote)
mimportmessage
tb = mkRemoteTrackingBranch remote branch

View file

@ -1,7 +1,7 @@
{- git-annex command
-
- Copyright 2011 Joachim Breitner <mail@joachim-breitner.de>
- Copyright 2011-2024 Joey Hess <id@joeyh.name>
- Copyright 2011-2023 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -105,7 +105,7 @@ data SyncOptions = SyncOptions
, notOnlyAnnexOption :: Bool
, commitOption :: Bool
, noCommitOption :: Bool
, messageOption :: [String]
, messageOption :: Maybe String
, pullOption :: Bool
, pushOption :: Bool
, contentOption :: Maybe Bool
@ -125,7 +125,7 @@ instance Default SyncOptions where
, notOnlyAnnexOption = False
, commitOption = False
, noCommitOption = False
, messageOption = []
, messageOption = Nothing
, 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] []
(many (strOption
<*> unlessmode [SyncMode, AssistMode] Nothing
(optional (strOption
( long "message" <> short 'm' <> metavar "MSG"
<> help "commit message"
)))
@ -402,18 +402,17 @@ 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" ] ++ mopts)
void $ inRepo $ Git.Branch.commitCommand cmode cquiet
[ Param "-a"
, Param "-m"
, Param commitmessage
]
return True
where
shouldcommit = notOnlyAnnex o <&&>
@ -427,8 +426,7 @@ 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) $
@ -580,7 +578,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) []
Command.Import.seekRemote remote branch subdir importcontent (CheckGitIgnore True) Nothing
-- Importing generates a branch
-- that is not initially connected
-- to the current branch, so allow