diff --git a/CHANGELOG b/CHANGELOG index e3c989f141..5b654f2f58 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,7 +7,6 @@ git-annex (10.20230803) UNRELEASED; urgency=medium * Fix behavior when importing a tree from a directory remote when the directory does not exist. An empty tree was imported, rather than the import failing. - * Stop bundling curl in the OSX dmg and linux standalone image. * sync, assist, push, pull: Skip more types of remotes when they are not present due to eg being on a drive that is offline. (directory, borg, bup, ddar, gcrypt, rsync) @@ -18,6 +17,9 @@ git-annex (10.20230803) UNRELEASED; urgency=medium * Avoid using curl when annex.security.allowed-ip-addresses is set but neither annex.web-options nor annex.security.allowed-url-schemes is set to a value that needs curl. + * Stop bundling curl in the OSX dmg and linux standalone image. + * diffdriver: Added --get option. + * diffdriver: Refuse to run when not in a git-annex repository. -- Joey Hess Mon, 07 Aug 2023 13:04:13 -0400 diff --git a/Command/DiffDriver.hs b/Command/DiffDriver.hs index d4057763ac..5bac213975 100644 --- a/Command/DiffDriver.hs +++ b/Command/DiffDriver.hs @@ -11,15 +11,16 @@ import Command import Annex.Content import Annex.Link import Git.Types +import qualified Command.Get cmd :: Command -cmd = dontCheck repoExists $ - command "diffdriver" SectionPlumbing - "git diff driver" - ("-- cmd --") (seek <$$> optParser) +cmd = command "diffdriver" SectionPlumbing + "git diff driver" + ("-- cmd --") (seek <$$> optParser) data Options = Options { textDiff :: Bool + , getOption :: Bool , restOptions :: CmdParams } @@ -29,16 +30,16 @@ optParser desc = Options ( long "text" <> help "diff text files with diff(1)" ) + <*> switch + ( long "get" + <> help "get file contents from remotes" + ) <*> cmdParams desc seek :: Options -> CommandSeek -seek = commandAction . start - -start :: Options -> CommandStart -start opts = do +seek opts = do let (req, differ) = parseReq opts - void $ liftIO . exitBool =<< liftIO . differ =<< fixupReq req - stop + void $ liftIO . exitBool =<< liftIO . differ =<< fixupReq req opts data Req = Req @@ -99,22 +100,35 @@ parseReq opts - - In either case, adjust the Req to instead point to the actual - location of the annexed object (which may or may not be present). + - + - This also gets objects from remotes when the getOption is set. -} -fixupReq :: Req -> Annex Req -fixupReq req@(UnmergedReq {}) = return req -fixupReq req@(Req {}) = +fixupReq :: Req -> Options -> Annex Req +fixupReq req@(UnmergedReq {}) _ = return req +fixupReq req@(Req {}) opts = check rOldFile rOldMode (\r f -> r { rOldFile = f }) req >>= check rNewFile rNewMode (\r f -> r { rNewFile = f }) where check getfile getmode setfile r = case readTreeItemType (encodeBS (getmode r)) of Just TreeSymlink -> do v <- getAnnexLinkTarget' f False - maybe (return r) repoint (parseLinkTargetOrPointer =<< v) - _ -> maybe (return r) repoint =<< liftIO (isPointerFile f) + maybe (return r) go (parseLinkTargetOrPointer =<< v) + _ -> maybe (return r) go =<< liftIO (isPointerFile f) where + f = toRawFilePath (getfile r) + go k = do + when (getOption opts) $ + unlessM (inAnnex k) $ + commandAction $ + starting "get" ai si $ + Command.Get.perform k af + repoint k + where + ai = OnlyActionOn k (ActionItemKey k) + si = SeekInput [] + af = AssociatedFile (Just f) repoint k = withObjectLoc k $ pure . setfile r . fromRawFilePath - f = toRawFilePath (getfile r) externalDiffer :: String -> [String] -> Differ externalDiffer c ps = \req -> boolSystem c (map Param ps ++ serializeReq req ) diff --git a/doc/git-annex-diffdriver.mdwn b/doc/git-annex-diffdriver.mdwn index c2c2537cf5..4669838955 100644 --- a/doc/git-annex-diffdriver.mdwn +++ b/doc/git-annex-diffdriver.mdwn @@ -4,9 +4,9 @@ git-annex diffdriver - git diff driver # SYNOPSIS -git annex diffdriver --text [-- --opts --] +`git annex diffdriver [--get,--text] [-- --diffopts --]` -git annex diffdriver `-- cmd --opts --` +`git annex diffdriver -- cmd --cmdopts --` # DESCRIPTION @@ -41,7 +41,11 @@ set `GIT_EXTERNAL_DIFF="git-annex diffdriver -- j-c-diff --"` # OPTIONS -To diff text files with diff(1), use the "--text" option. +To get the contents of annexed files from remotes when they are not already +present, use the `--get` option. The file contents will remain in the +repository for later use until dropped in the usual ways. + +To diff text files with diff(1), use the `--text` option. To pass additional options to diff(1), use eg "--text -- --color --" To use an external diff driver command, the options must start with diff --git a/doc/todo/--get_option_for_diffdriver.mdwn b/doc/todo/--get_option_for_diffdriver.mdwn index 471814ae9d..6e424d0293 100644 --- a/doc/todo/--get_option_for_diffdriver.mdwn +++ b/doc/todo/--get_option_for_diffdriver.mdwn @@ -1,3 +1,5 @@ since there is no generic 'fuse' mode, I would like to request to have `--get` (or `--auto-get`) option for diffdriver. I am trying to compare files across two branches on a repo I just cloned. I cannot download all the files and downloading differing keys across branches for the same file is a bit painful. So I felt that it would be super nice if git annex could auto get those files from somewhere (well -- original clone) [[!tag confirmed]] + +> [[done]] --[[Joey]]