From: Joey Hess Date: Thu, 18 Jan 2024 16:41:44 +0000 (-0400) Subject: import: --message/-m option X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~29^2~35 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e765d3e24ca4f1a65b7374d2485f77f916d7d3bd;p=git-annex.git import: --message/-m option --- diff --git a/CHANGELOG b/CHANGELOG index 5398bacdcb..20278c8ba3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ git-annex (10.20231228) UNRELEASED; urgency=medium key algorithm and size. * Improve disk free space checking when transferring unsized keys to local git remotes. + * import: --message/-m option. -- Joey Hess Fri, 29 Dec 2023 11:52:06 -0400 diff --git a/Command/Import.hs b/Command/Import.hs index b3cf4d4ad1..a37064eefc 100644 --- a/Command/Import.hs +++ b/Command/Import.hs @@ -70,6 +70,7 @@ data ImportOptions , importToSubDir :: Maybe FilePath , importContent :: Bool , checkGitIgnoreOption :: CheckGitIgnore + , messageOption :: Maybe String } optParser :: CmdParamsDesc -> Parser ImportOptions @@ -81,7 +82,11 @@ optParser desc = do ) dupmode <- fromMaybe Default <$> optional duplicateModeParser ic <- Command.Add.checkGitIgnoreSwitch - return $ case mfromremote of + message <- optional (strOption + ( long "message" <> short 'm' <> metavar "MSG" + <> help "commit message" + )) + pure $ case mfromremote of Nothing -> LocalImportOptions ps dupmode ic Just r -> case ps of [bs] -> @@ -91,6 +96,7 @@ optParser desc = do (if null subdir then Nothing else Just subdir) content ic + message _ -> giveup "expected BRANCH[:SUBDIR]" data DuplicateMode = Default | Duplicate | DeDuplicate | CleanDuplicates | SkipDuplicates | ReinjectDuplicates @@ -141,7 +147,9 @@ seek o@(RemoteImportOptions {}) = startConcurrency commandStages $ do (pure Nothing) (Just <$$> inRepo . toTopFilePath . toRawFilePath) (importToSubDir o) - seekRemote r (importToBranch o) subdir (importContent o) (checkGitIgnoreOption o) + seekRemote r (importToBranch o) subdir (importContent o) + (checkGitIgnoreOption o) + (messageOption o) startLocal :: ImportOptions -> AddUnlockedMatcher -> GetFileMatcher -> DuplicateMode -> (RawFilePath, RawFilePath) -> CommandStart startLocal o addunlockedmatcher largematcher mode (srcfile, destfile) = @@ -314,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 -> CommandSeek -seekRemote remote branch msubdir importcontent ci = 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 -> @@ -345,7 +353,9 @@ seekRemote remote branch msubdir importcontent ci = do includeCommandAction $ commitimport imported where - importmessage = "import from " ++ Remote.name remote + importmessage = fromMaybe + ("import from " ++ Remote.name remote) + mimportmessage tb = mkRemoteTrackingBranch remote branch diff --git a/Command/Sync.hs b/Command/Sync.hs index 260740d5b5..c4cbb0ccd1 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -591,7 +591,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 diff --git a/doc/bugs/Request_the_ability_to_specify_pull_commit_message/.comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment.swp b/doc/bugs/Request_the_ability_to_specify_pull_commit_message/.comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment.swp new file mode 100644 index 0000000000..1a6dfc94db Binary files /dev/null and b/doc/bugs/Request_the_ability_to_specify_pull_commit_message/.comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment.swp differ diff --git a/doc/bugs/Request_the_ability_to_specify_pull_commit_message/comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment b/doc/bugs/Request_the_ability_to_specify_pull_commit_message/comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment new file mode 100644 index 0000000000..db1e45acc5 --- /dev/null +++ b/doc/bugs/Request_the_ability_to_specify_pull_commit_message/comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment @@ -0,0 +1,23 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2024-01-18T16:18:38Z" + content=""" +This would need to start with `git-annex import --from=remote` +getting a `--message` option. Which I've just implemented. + +As for adding an option to `git-annex pull`, it would need to be an option +other than `--message`, because `git-annex sync` already uses `--message` +for the commit message. And since `git-annex pull` can pull from more than +one remote at a time, it seems that it would need an option that specifies +a message plus which remote to use that message for. Or the option +would need to only be used when using `git-annex pull` with a single +specified remote. + +That seems like perhaps unncessary complexity, since if you want to import +a tree from a remote and specify a message, you can just use +`git-annex import` with `--message` now. +And then you can run `git-annex pull` to proceed with the rest of what it does. + +Good enough? +"""]] diff --git a/doc/git-annex-import.mdwn b/doc/git-annex-import.mdwn index 9844e239ee..b72fae5d5f 100644 --- a/doc/git-annex-import.mdwn +++ b/doc/git-annex-import.mdwn @@ -102,6 +102,11 @@ the tree of files on the remote, even when importing into a subdirectory. `git-annex get` can later be used to download files, as desired. The --no-content option is not supported by all special remotes. +* `--message=msg` `-m msg` + + 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. + # IMPORTING FROM A DIRECTORY When run with a path, `git annex import` **moves** files from somewhere outside