diffdriver: Added --get option
Removed the dontCheck repoExists, because running it in a repo that has not been initialized yet would update location log with nouuid. And I guess it's ok for it to only support running in git-annex repos.
This commit is contained in:
parent
724ceeb1a9
commit
379d58b499
4 changed files with 42 additions and 20 deletions
|
@ -7,7 +7,6 @@ git-annex (10.20230803) UNRELEASED; urgency=medium
|
||||||
* Fix behavior when importing a tree from a directory remote when the
|
* Fix behavior when importing a tree from a directory remote when the
|
||||||
directory does not exist. An empty tree was imported, rather than the
|
directory does not exist. An empty tree was imported, rather than the
|
||||||
import failing.
|
import failing.
|
||||||
* Stop bundling curl in the OSX dmg and linux standalone image.
|
|
||||||
* sync, assist, push, pull: Skip more types of remotes when they
|
* sync, assist, push, pull: Skip more types of remotes when they
|
||||||
are not present due to eg being on a drive that is offline.
|
are not present due to eg being on a drive that is offline.
|
||||||
(directory, borg, bup, ddar, gcrypt, rsync)
|
(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
|
* Avoid using curl when annex.security.allowed-ip-addresses is set
|
||||||
but neither annex.web-options nor annex.security.allowed-url-schemes
|
but neither annex.web-options nor annex.security.allowed-url-schemes
|
||||||
is set to a value that needs curl.
|
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 <id@joeyh.name> Mon, 07 Aug 2023 13:04:13 -0400
|
-- Joey Hess <id@joeyh.name> Mon, 07 Aug 2023 13:04:13 -0400
|
||||||
|
|
||||||
|
|
|
@ -11,15 +11,16 @@ import Command
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Annex.Link
|
import Annex.Link
|
||||||
import Git.Types
|
import Git.Types
|
||||||
|
import qualified Command.Get
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = dontCheck repoExists $
|
cmd = command "diffdriver" SectionPlumbing
|
||||||
command "diffdriver" SectionPlumbing
|
"git diff driver"
|
||||||
"git diff driver"
|
("-- cmd --") (seek <$$> optParser)
|
||||||
("-- cmd --") (seek <$$> optParser)
|
|
||||||
|
|
||||||
data Options = Options
|
data Options = Options
|
||||||
{ textDiff :: Bool
|
{ textDiff :: Bool
|
||||||
|
, getOption :: Bool
|
||||||
, restOptions :: CmdParams
|
, restOptions :: CmdParams
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,16 +30,16 @@ optParser desc = Options
|
||||||
( long "text"
|
( long "text"
|
||||||
<> help "diff text files with diff(1)"
|
<> help "diff text files with diff(1)"
|
||||||
)
|
)
|
||||||
|
<*> switch
|
||||||
|
( long "get"
|
||||||
|
<> help "get file contents from remotes"
|
||||||
|
)
|
||||||
<*> cmdParams desc
|
<*> cmdParams desc
|
||||||
|
|
||||||
seek :: Options -> CommandSeek
|
seek :: Options -> CommandSeek
|
||||||
seek = commandAction . start
|
seek opts = do
|
||||||
|
|
||||||
start :: Options -> CommandStart
|
|
||||||
start opts = do
|
|
||||||
let (req, differ) = parseReq opts
|
let (req, differ) = parseReq opts
|
||||||
void $ liftIO . exitBool =<< liftIO . differ =<< fixupReq req
|
void $ liftIO . exitBool =<< liftIO . differ =<< fixupReq req opts
|
||||||
stop
|
|
||||||
|
|
||||||
data Req
|
data Req
|
||||||
= Req
|
= Req
|
||||||
|
@ -99,22 +100,35 @@ parseReq opts
|
||||||
-
|
-
|
||||||
- In either case, adjust the Req to instead point to the actual
|
- In either case, adjust the Req to instead point to the actual
|
||||||
- location of the annexed object (which may or may not be present).
|
- 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 -> Options -> Annex Req
|
||||||
fixupReq req@(UnmergedReq {}) = return req
|
fixupReq req@(UnmergedReq {}) _ = return req
|
||||||
fixupReq req@(Req {}) =
|
fixupReq req@(Req {}) opts =
|
||||||
check rOldFile rOldMode (\r f -> r { rOldFile = f }) req
|
check rOldFile rOldMode (\r f -> r { rOldFile = f }) req
|
||||||
>>= check rNewFile rNewMode (\r f -> r { rNewFile = f })
|
>>= check rNewFile rNewMode (\r f -> r { rNewFile = f })
|
||||||
where
|
where
|
||||||
check getfile getmode setfile r = case readTreeItemType (encodeBS (getmode r)) of
|
check getfile getmode setfile r = case readTreeItemType (encodeBS (getmode r)) of
|
||||||
Just TreeSymlink -> do
|
Just TreeSymlink -> do
|
||||||
v <- getAnnexLinkTarget' f False
|
v <- getAnnexLinkTarget' f False
|
||||||
maybe (return r) repoint (parseLinkTargetOrPointer =<< v)
|
maybe (return r) go (parseLinkTargetOrPointer =<< v)
|
||||||
_ -> maybe (return r) repoint =<< liftIO (isPointerFile f)
|
_ -> maybe (return r) go =<< liftIO (isPointerFile f)
|
||||||
where
|
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 $
|
repoint k = withObjectLoc k $
|
||||||
pure . setfile r . fromRawFilePath
|
pure . setfile r . fromRawFilePath
|
||||||
f = toRawFilePath (getfile r)
|
|
||||||
|
|
||||||
externalDiffer :: String -> [String] -> Differ
|
externalDiffer :: String -> [String] -> Differ
|
||||||
externalDiffer c ps = \req -> boolSystem c (map Param ps ++ serializeReq req )
|
externalDiffer c ps = \req -> boolSystem c (map Param ps ++ serializeReq req )
|
||||||
|
|
|
@ -4,9 +4,9 @@ git-annex diffdriver - git diff driver
|
||||||
|
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
|
|
||||||
git annex diffdriver --text [-- --opts --]
|
`git annex diffdriver [--get,--text] [-- --diffopts --]`
|
||||||
|
|
||||||
git annex diffdriver `-- cmd --opts --`
|
`git annex diffdriver -- cmd --cmdopts --`
|
||||||
|
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
|
|
||||||
|
@ -41,7 +41,11 @@ set `GIT_EXTERNAL_DIFF="git-annex diffdriver -- j-c-diff --"`
|
||||||
|
|
||||||
# OPTIONS
|
# 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 pass additional options to diff(1), use eg "--text -- --color --"
|
||||||
|
|
||||||
To use an external diff driver command, the options must start with
|
To use an external diff driver command, the options must start with
|
||||||
|
|
|
@ -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)
|
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]]
|
[[!tag confirmed]]
|
||||||
|
|
||||||
|
> [[done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue