push: Support --cleanup

This option is not specific to sync, so it seemed it should be in either
pull or push as well as sync. Since it does modify the remote, it seems
better to have it in push; the modification of the local repo pulls in
the direction of pull, but not hard enough.

Maybe it would be better to have it in both?

Sponsored-by: Luke Shumaker on Patreon
This commit is contained in:
Joey Hess 2023-05-17 12:46:22 -04:00
parent 31d21578c3
commit af6b73a7e6
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 29 additions and 31 deletions

View file

@ -151,15 +151,15 @@ optParser mode desc = SyncOptions
( long "not-only-annex"
<> help "operate on git branches as well as annex"
)
<*> unlesssync False (switch
<*> unlessmode SyncMode False (switch
( long "commit"
<> help "commit changes to git"
))
<*> unlesssync True (switch
<*> unlessmode SyncMode True (switch
( long "no-commit"
<> help "avoid git commit"
))
<*> unlesssync Nothing (optional (strOption
<*> unlessmode SyncMode Nothing (optional (strOption
( long "message" <> short 'm' <> metavar "MSG"
<> help "commit message"
)))
@ -190,24 +190,22 @@ optParser mode desc = SyncOptions
<> help "transfer contents of annexed files in a given location"
<> metavar paramPath
))
<*> unlesssync False (switch
<*> unlessmode PullMode False (switch
( long "cleanup"
<> help "remove synced/ branches from previous sync"
))
<*> optional parseAllOption
<*> case mode of
PushMode -> pure False
_ -> invertableSwitch "resolvemerge" True
( help "do not automatically resolve merge conflicts"
)
<*> unlessmode PushMode False (invertableSwitch "resolvemerge" True
( help "do not automatically resolve merge conflicts"
))
<*> case mode of
PushMode -> pure False
_ -> parseUnrelatedHistoriesOption
<*> pure mode
where
unlesssync v a = case mode of
SyncMode -> a
_ -> pure v
unlessmode m v a
| mode /= m = a
| otherwise = pure v
parseUnrelatedHistoriesOption :: Parser Bool
parseUnrelatedHistoriesOption =