New annex.synccontent config setting
.. which can be set to true to make git annex sync default to --content. This may become the default at some point in the future. As well as being configuable by git config, it can be configured by git-annex config to control the default behavior in all clones of a repository. Had to add a separate --no-content switch to we can tell if it's been explicitly set, and should override annex.synccontent. If --content was the default, this complication would not be necessary. This commit was sponsored by Jake Vosloo on Patreon.
This commit is contained in:
parent
ed56dba868
commit
b77903af48
6 changed files with 53 additions and 18 deletions
|
@ -7,8 +7,11 @@ git-annex (6.20170102) UNRELEASED; urgency=medium
|
||||||
taken for --json.
|
taken for --json.
|
||||||
* vicfg: Include the numcopies configuation.
|
* vicfg: Include the numcopies configuation.
|
||||||
* config: New command for storing configuration in the git-annex branch.
|
* config: New command for storing configuration in the git-annex branch.
|
||||||
* annex.autocommit can be configured via git-annex config, to control
|
* New annex.synccontent config setting, which can be set to true to make
|
||||||
the default behavior in all clones of a repository.
|
git annex sync default to --content. This may become the default at
|
||||||
|
some point in the future. As well as being configuable by git config,
|
||||||
|
it can be configured by git-annex config to control the default
|
||||||
|
behavior in all clones of a repository.
|
||||||
* stack.yaml: Update to lts-7.18.
|
* stack.yaml: Update to lts-7.18.
|
||||||
* Some optimisations to string splitting code.
|
* Some optimisations to string splitting code.
|
||||||
* unused: When large files are checked right into git, avoid buffering
|
* unused: When large files are checked right into git, avoid buffering
|
||||||
|
|
|
@ -70,6 +70,7 @@ data SyncOptions = SyncOptions
|
||||||
, pullOption :: Bool
|
, pullOption :: Bool
|
||||||
, pushOption :: Bool
|
, pushOption :: Bool
|
||||||
, contentOption :: Bool
|
, contentOption :: Bool
|
||||||
|
, noContentOption :: Bool
|
||||||
, keyOptions :: Maybe KeyOptions
|
, keyOptions :: Maybe KeyOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +93,13 @@ optParser desc = SyncOptions
|
||||||
<*> invertableSwitch "push" True
|
<*> invertableSwitch "push" True
|
||||||
( help "avoid git pushes to remotes"
|
( help "avoid git pushes to remotes"
|
||||||
)
|
)
|
||||||
<*> invertableSwitch "content" False
|
<*> switch
|
||||||
( help "also transfer file contents"
|
( long "content"
|
||||||
|
<> help "transfer file contents"
|
||||||
|
)
|
||||||
|
<*> switch
|
||||||
|
( long "no-content"
|
||||||
|
<> help "do not transfer file contents"
|
||||||
)
|
)
|
||||||
<*> optional parseAllOption
|
<*> optional parseAllOption
|
||||||
|
|
||||||
|
@ -118,21 +124,23 @@ seek o = allowConcurrentOutput $ do
|
||||||
, map (withbranch . pullRemote o mergeConfig) gitremotes
|
, map (withbranch . pullRemote o mergeConfig) gitremotes
|
||||||
, [ mergeAnnex ]
|
, [ mergeAnnex ]
|
||||||
]
|
]
|
||||||
when (contentOption o) $
|
whenM (shouldsynccontent <&&> seekSyncContent o dataremotes) $
|
||||||
whenM (seekSyncContent o dataremotes) $
|
-- Transferring content can take a while,
|
||||||
-- Transferring content can take a while,
|
-- and other changes can be pushed to the git-annex
|
||||||
-- and other changes can be pushed to the git-annex
|
-- branch on the remotes in the meantime, so pull
|
||||||
-- branch on the remotes in the meantime, so pull
|
-- and merge again to avoid our push overwriting
|
||||||
-- and merge again to avoid our push overwriting
|
-- those changes.
|
||||||
-- those changes.
|
mapM_ includeCommandAction $ concat
|
||||||
mapM_ includeCommandAction $ concat
|
[ map (withbranch . pullRemote o mergeConfig) gitremotes
|
||||||
[ map (withbranch . pullRemote o mergeConfig) gitremotes
|
, [ commitAnnex, mergeAnnex ]
|
||||||
, [ commitAnnex, mergeAnnex ]
|
]
|
||||||
]
|
|
||||||
|
|
||||||
void $ includeCommandAction $ withbranch pushLocal
|
void $ includeCommandAction $ withbranch pushLocal
|
||||||
-- Pushes to remotes can run concurrently.
|
-- Pushes to remotes can run concurrently.
|
||||||
mapM_ (commandAction . withbranch . pushRemote o) gitremotes
|
mapM_ (commandAction . withbranch . pushRemote o) gitremotes
|
||||||
|
where
|
||||||
|
shouldsynccontent = pure (contentOption o)
|
||||||
|
<||> (pure (not (noContentOption o)) <&&> getGitConfigVal annexSyncContent)
|
||||||
|
|
||||||
type CurrBranch = (Maybe Git.Branch, Maybe Adjustment)
|
type CurrBranch = (Maybe Git.Branch, Maybe Adjustment)
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ data Configurable a
|
||||||
| DefaultConfig a
|
| DefaultConfig a
|
||||||
-- ^ A default value is known, but not all config sources
|
-- ^ A default value is known, but not all config sources
|
||||||
-- have been read yet.
|
-- have been read yet.
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
{- Main git-annex settings. Each setting corresponds to a git-config key
|
{- Main git-annex settings. Each setting corresponds to a git-config key
|
||||||
- such as annex.foo -}
|
- such as annex.foo -}
|
||||||
|
@ -57,6 +58,7 @@ data GitConfig = GitConfig
|
||||||
, annexHttpHeaders :: [String]
|
, annexHttpHeaders :: [String]
|
||||||
, annexHttpHeadersCommand :: Maybe String
|
, annexHttpHeadersCommand :: Maybe String
|
||||||
, annexAutoCommit :: Configurable Bool
|
, annexAutoCommit :: Configurable Bool
|
||||||
|
, annexSyncContent :: Configurable Bool
|
||||||
, annexDebug :: Bool
|
, annexDebug :: Bool
|
||||||
, annexWebOptions :: [String]
|
, annexWebOptions :: [String]
|
||||||
, annexQuviOptions :: [String]
|
, annexQuviOptions :: [String]
|
||||||
|
@ -105,6 +107,8 @@ extractGitConfig r = GitConfig
|
||||||
, annexHttpHeadersCommand = getmaybe (annex "http-headers-command")
|
, annexHttpHeadersCommand = getmaybe (annex "http-headers-command")
|
||||||
, annexAutoCommit = configurable True $
|
, annexAutoCommit = configurable True $
|
||||||
getmaybebool (annex "autocommit")
|
getmaybebool (annex "autocommit")
|
||||||
|
, annexSyncContent = configurable False $
|
||||||
|
getmaybebool (annex "synccontent")
|
||||||
, annexDebug = getbool (annex "debug") False
|
, annexDebug = getbool (annex "debug") False
|
||||||
, annexWebOptions = getwords (annex "web-options")
|
, annexWebOptions = getwords (annex "web-options")
|
||||||
, annexQuviOptions = getwords (annex "quvi-options")
|
, annexQuviOptions = getwords (annex "quvi-options")
|
||||||
|
@ -156,6 +160,7 @@ extractGitConfig r = GitConfig
|
||||||
mergeGitConfig :: GitConfig -> GitConfig -> GitConfig
|
mergeGitConfig :: GitConfig -> GitConfig -> GitConfig
|
||||||
mergeGitConfig gitconfig repoglobals = gitconfig
|
mergeGitConfig gitconfig repoglobals = gitconfig
|
||||||
{ annexAutoCommit = merge annexAutoCommit
|
{ annexAutoCommit = merge annexAutoCommit
|
||||||
|
, annexSyncContent = merge annexSyncContent
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
merge f = case f gitconfig of
|
merge f = case f gitconfig of
|
||||||
|
|
|
@ -32,6 +32,10 @@ These settings can be overridden on a per-repository basis using
|
||||||
Set to false to prevent the git-annex assistant and git-annex sync
|
Set to false to prevent the git-annex assistant and git-annex sync
|
||||||
from automatically committing changes to files in the repository.
|
from automatically committing changes to files in the repository.
|
||||||
|
|
||||||
|
* `annex.synccontent`
|
||||||
|
|
||||||
|
Set to true to make git-annex sync default to syncing content.
|
||||||
|
|
||||||
# EXAMPLE
|
# EXAMPLE
|
||||||
|
|
||||||
Suppose you want to prevent git annex sync from committing changes
|
Suppose you want to prevent git annex sync from committing changes
|
||||||
|
@ -40,7 +44,12 @@ repository. Then run:
|
||||||
|
|
||||||
git annex config --set annex.autocommit false
|
git annex config --set annex.autocommit false
|
||||||
|
|
||||||
If you change your mind, you can get back to the default behavior:
|
If you want to override that in a partiticular clone, just use git config
|
||||||
|
in the clone:
|
||||||
|
|
||||||
|
git config annex.autocommit true
|
||||||
|
|
||||||
|
And to get back to the default behavior:
|
||||||
|
|
||||||
git annex config --unset annex.autocommit
|
git annex config --unset annex.autocommit
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,9 @@ by running "git annex sync" on the remote.
|
||||||
The --content option causes the content of files in the work tree
|
The --content option causes the content of files in the work tree
|
||||||
to also be uploaded and downloaded as necessary.
|
to also be uploaded and downloaded as necessary.
|
||||||
|
|
||||||
|
The annex.synccontent configuration can be set to true to make content
|
||||||
|
be synced by default.
|
||||||
|
|
||||||
Normally this tries to get each annexed file in the work tree
|
Normally this tries to get each annexed file in the work tree
|
||||||
that the local repository does not yet have, and then copies each
|
that the local repository does not yet have, and then copies each
|
||||||
file in the work tree to every remote that it is syncing with.
|
file in the work tree to every remote that it is syncing with.
|
||||||
|
|
|
@ -1009,6 +1009,13 @@ Here are all the supported configuration settings.
|
||||||
To configure the behavior in all clones of the repository,
|
To configure the behavior in all clones of the repository,
|
||||||
this can be set in [[git-annex-config]].
|
this can be set in [[git-annex-config]].
|
||||||
|
|
||||||
|
* `annex.synccontent`
|
||||||
|
|
||||||
|
Set to true to make git-annex sync default to syncing content.
|
||||||
|
|
||||||
|
To configure the behavior in all clones of the repository,
|
||||||
|
this can be set in [[git-annex-config]].
|
||||||
|
|
||||||
* `annex.startupscan`
|
* `annex.startupscan`
|
||||||
|
|
||||||
Set to false to prevent the git-annex assistant from scanning the
|
Set to false to prevent the git-annex assistant from scanning the
|
||||||
|
|
Loading…
Reference in a new issue