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
|
@ -70,6 +70,7 @@ data SyncOptions = SyncOptions
|
|||
, pullOption :: Bool
|
||||
, pushOption :: Bool
|
||||
, contentOption :: Bool
|
||||
, noContentOption :: Bool
|
||||
, keyOptions :: Maybe KeyOptions
|
||||
}
|
||||
|
||||
|
@ -92,8 +93,13 @@ optParser desc = SyncOptions
|
|||
<*> invertableSwitch "push" True
|
||||
( help "avoid git pushes to remotes"
|
||||
)
|
||||
<*> invertableSwitch "content" False
|
||||
( help "also transfer file contents"
|
||||
<*> switch
|
||||
( long "content"
|
||||
<> help "transfer file contents"
|
||||
)
|
||||
<*> switch
|
||||
( long "no-content"
|
||||
<> help "do not transfer file contents"
|
||||
)
|
||||
<*> optional parseAllOption
|
||||
|
||||
|
@ -118,22 +124,24 @@ seek o = allowConcurrentOutput $ do
|
|||
, map (withbranch . pullRemote o mergeConfig) gitremotes
|
||||
, [ mergeAnnex ]
|
||||
]
|
||||
when (contentOption o) $
|
||||
whenM (seekSyncContent o dataremotes) $
|
||||
-- Transferring content can take a while,
|
||||
-- and other changes can be pushed to the git-annex
|
||||
-- branch on the remotes in the meantime, so pull
|
||||
-- and merge again to avoid our push overwriting
|
||||
-- those changes.
|
||||
mapM_ includeCommandAction $ concat
|
||||
[ map (withbranch . pullRemote o mergeConfig) gitremotes
|
||||
, [ commitAnnex, mergeAnnex ]
|
||||
]
|
||||
whenM (shouldsynccontent <&&> seekSyncContent o dataremotes) $
|
||||
-- Transferring content can take a while,
|
||||
-- and other changes can be pushed to the git-annex
|
||||
-- branch on the remotes in the meantime, so pull
|
||||
-- and merge again to avoid our push overwriting
|
||||
-- those changes.
|
||||
mapM_ includeCommandAction $ concat
|
||||
[ map (withbranch . pullRemote o mergeConfig) gitremotes
|
||||
, [ commitAnnex, mergeAnnex ]
|
||||
]
|
||||
|
||||
void $ includeCommandAction $ withbranch pushLocal
|
||||
-- Pushes to remotes can run concurrently.
|
||||
mapM_ (commandAction . withbranch . pushRemote o) gitremotes
|
||||
|
||||
where
|
||||
shouldsynccontent = pure (contentOption o)
|
||||
<||> (pure (not (noContentOption o)) <&&> getGitConfigVal annexSyncContent)
|
||||
|
||||
type CurrBranch = (Maybe Git.Branch, Maybe Adjustment)
|
||||
|
||||
{- There may not be a branch checked out until after the commit,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue