add --sameas option, not yet used
This commit is contained in:
parent
7b5ce2b330
commit
61b384d2b7
6 changed files with 65 additions and 8 deletions
|
@ -14,6 +14,8 @@ git-annex (7.20190913) UNRELEASED; urgency=medium
|
|||
* Fix bug in handling of annex.largefiles that use largerthan/smallerthan.
|
||||
When adding a modified file, it incorrectly used the file size of the
|
||||
old version of the file, not the current size.
|
||||
* initremote: Added --sameas option, allows for two special remotes that
|
||||
access the same data store.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Thu, 19 Sep 2019 11:11:19 -0400
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{- git-annex command-line option parsing
|
||||
-
|
||||
- Copyright 2010-2018 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2019 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -114,6 +114,10 @@ parseRemoteOption = DeferredParse
|
|||
. (fromJust <$$> Remote.byNameWithUUID)
|
||||
. Just
|
||||
|
||||
parseUUIDOption :: String -> DeferredParse UUID
|
||||
parseUUIDOption = DeferredParse
|
||||
. (Remote.nameToUUID)
|
||||
|
||||
-- | From or To a remote.
|
||||
data FromToOptions
|
||||
= FromRemote (DeferredParse Remote)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2011,2013 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2011-2019 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -21,14 +21,32 @@ cmd :: Command
|
|||
cmd = command "initremote" SectionSetup
|
||||
"creates a special (non-git) remote"
|
||||
(paramPair paramName $ paramOptional $ paramRepeating paramKeyValue)
|
||||
(withParams seek)
|
||||
(seek <$$> optParser)
|
||||
|
||||
seek :: CmdParams -> CommandSeek
|
||||
seek = withWords (commandAction . start)
|
||||
data InitRemoteOptions = InitRemoteOptions
|
||||
{ cmdparams :: CmdParams
|
||||
, sameas :: Maybe (DeferredParse UUID)
|
||||
}
|
||||
|
||||
start :: [String] -> CommandStart
|
||||
start [] = giveup "Specify a name for the remote."
|
||||
start (name:ws) = ifM (isJust <$> findExisting name)
|
||||
optParser :: CmdParamsDesc -> Parser InitRemoteOptions
|
||||
optParser desc = InitRemoteOptions
|
||||
<$> cmdParams desc
|
||||
<*> optional parseSameasOption
|
||||
|
||||
parseSameasOption :: Parser (DeferredParse UUID)
|
||||
parseSameasOption = parseUUIDOption <$> strOption
|
||||
( long "sameas"
|
||||
<> metavar (paramRemote `paramOr` paramDesc `paramOr` paramUUID)
|
||||
<> help "new remote that accesses the same data"
|
||||
<> completeRemotes
|
||||
)
|
||||
|
||||
seek :: InitRemoteOptions -> CommandSeek
|
||||
seek o = withWords (commandAction . (start o)) (cmdparams o)
|
||||
|
||||
start :: InitRemoteOptions -> [String] -> CommandStart
|
||||
start _ [] = giveup "Specify a name for the remote."
|
||||
start o (name:ws) = ifM (isJust <$> findExisting name)
|
||||
( giveup $ "There is already a special remote named \"" ++ name ++
|
||||
"\". (Use enableremote to enable an existing special remote.)"
|
||||
, do
|
||||
|
|
|
@ -43,6 +43,20 @@ want to use `git annex renameremote`.
|
|||
and re-run with `--fast`, which causes it to use a lower-quality source of
|
||||
randomness. (Ie, /dev/urandom instead of /dev/random)
|
||||
|
||||
* `--sameas=remote`
|
||||
|
||||
Use this when the new special remote uses the same underlying storage
|
||||
as some other remote. This will result in the new special remote having
|
||||
the same uuid as the specified remote, and either can be used to access
|
||||
the same content.
|
||||
|
||||
The `remote` can be the name of a git remote, or the description
|
||||
or uuid of any git-annex repository.
|
||||
|
||||
When using this option, the new remote inherits the encryption settings
|
||||
of the existing remote, so you should not specify any encryption
|
||||
parameters. No other configuration is inherited from the existing remote.
|
||||
|
||||
# COMMON CONFIGURATION PARAMETERS
|
||||
|
||||
* `encryption`
|
||||
|
|
|
@ -14,6 +14,11 @@ two. url=http:// url=ssh:// won't work, only one value will be used.
|
|||
url1= url2= is annoying for the user, especially if they later want to add
|
||||
another url with enableremote and have to work out the number.
|
||||
|
||||
> If each url is treated as a separate special remote (which makes a lot of sense
|
||||
> by analogy with how regular git remotes work), then
|
||||
> [[support_multiple_special_remotes_with_same_uuid]] could be used to
|
||||
> solve this.
|
||||
|
||||
Problem: The user might go in and change the remote's url to point to some
|
||||
other server with a different git-lfs backend. In fact, they could already
|
||||
do so! Remembering the urls actually would let the special remote detect
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 4"""
|
||||
date="2019-10-01T16:26:12Z"
|
||||
content="""
|
||||
The RemoteConfig is generated each run from the remote.log, and so the
|
||||
handling of sameas remotes needs to be done in Logs.Remote.readRemoteLog
|
||||
not by enableremote.
|
||||
|
||||
Logs.Remote.configSet will need some changes because it currently works
|
||||
on the basis of UUID, and so can't know when it's supposed to change a
|
||||
sameas remote. It seems it should instead work on the basis of the "name"
|
||||
field of the RemoteConfig.
|
||||
"""]]
|
Loading…
Reference in a new issue