Disable receive.denyNonFastForwards when setting up a gcrypt special remote
gcrypt needs to be able to fast-forward the master branch. If a git repository is set up with git init --shared --bare, it gets that set, and pushing to it will then fail, even when it's up-to-date.
This commit is contained in:
parent
0ddf4d3148
commit
1536ebfe47
3 changed files with 27 additions and 13 deletions
|
@ -177,3 +177,14 @@ fromFile r f = fromPipe r "git"
|
||||||
, File f
|
, File f
|
||||||
, Param "--list"
|
, Param "--list"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{- Changes a git config setting in the specified config file.
|
||||||
|
- (Creates the file if it does not already exist.) -}
|
||||||
|
changeFile :: FilePath -> String -> String -> IO Bool
|
||||||
|
changeFile f k v = boolSystem "git"
|
||||||
|
[ Param "config"
|
||||||
|
, Param "--file"
|
||||||
|
, File f
|
||||||
|
, Param k
|
||||||
|
, Param v
|
||||||
|
]
|
||||||
|
|
|
@ -191,8 +191,9 @@ gCryptSetup mu c = go $ M.lookup "gitrepo" c
|
||||||
- repo, or it is accessed via rsync directly, or it is accessed over ssh
|
- repo, or it is accessed via rsync directly, or it is accessed over ssh
|
||||||
- and git-annex-shell is available to manage it.
|
- and git-annex-shell is available to manage it.
|
||||||
-
|
-
|
||||||
- The gcrypt-id is stored in the gcrypt repository for later
|
- The GCryptID is recorded in the repository's git config for later use.
|
||||||
- double-checking and identification. This is always done using rsync.
|
- Also, if the git config has receive.denyNonFastForwards set, disable
|
||||||
|
- it; gcrypt relies on being able to fast-forward branches.
|
||||||
-}
|
-}
|
||||||
setupRepo :: Git.GCrypt.GCryptId -> Git.Repo -> Annex AccessMethod
|
setupRepo :: Git.GCrypt.GCryptId -> Git.Repo -> Annex AccessMethod
|
||||||
setupRepo gcryptid r
|
setupRepo gcryptid r
|
||||||
|
@ -208,14 +209,14 @@ setupRepo gcryptid r
|
||||||
| otherwise = localsetup r
|
| otherwise = localsetup r
|
||||||
where
|
where
|
||||||
localsetup r' = do
|
localsetup r' = do
|
||||||
liftIO $ Git.Command.run [Param "config", Param coreGCryptId, Param gcryptid] r'
|
let setconfig k v = liftIO $ Git.Command.run [Param "config", Param k, Param v] r'
|
||||||
|
setconfig coreGCryptId gcryptid
|
||||||
|
setconfig denyNonFastForwards (Git.Config.boolConfig False)
|
||||||
return AccessDirect
|
return AccessDirect
|
||||||
|
|
||||||
{- Download any git config file from the remote,
|
{- As well as modifying the remote's git config,
|
||||||
- add the gcryptid to it, and send it back.
|
- create the objectDir on the remote,
|
||||||
-
|
- which is needed for direct rsync of objects to work.
|
||||||
- At the same time, create the objectDir on the remote,
|
|
||||||
- which is needed for direct rsync to work.
|
|
||||||
-}
|
-}
|
||||||
rsyncsetup = Remote.Rsync.withRsyncScratchDir $ \tmp -> do
|
rsyncsetup = Remote.Rsync.withRsyncScratchDir $ \tmp -> do
|
||||||
liftIO $ createDirectoryIfMissing True $ tmp </> objectDir
|
liftIO $ createDirectoryIfMissing True $ tmp </> objectDir
|
||||||
|
@ -225,11 +226,9 @@ setupRepo gcryptid r
|
||||||
[ Param $ rsyncurl ++ "/config"
|
[ Param $ rsyncurl ++ "/config"
|
||||||
, Param tmpconfig
|
, Param tmpconfig
|
||||||
]
|
]
|
||||||
liftIO $ appendFile tmpconfig $ unlines
|
liftIO $ do
|
||||||
[ ""
|
Git.Config.changeFile tmpconfig coreGCryptId gcryptid
|
||||||
, "[core]"
|
Git.Config.changeFile tmpconfig denyNonFastForwards (Git.Config.boolConfig False)
|
||||||
, "\tgcrypt-id = " ++ gcryptid
|
|
||||||
]
|
|
||||||
ok <- liftIO $ rsync $ rsynctransport ++
|
ok <- liftIO $ rsync $ rsynctransport ++
|
||||||
[ Params "--recursive"
|
[ Params "--recursive"
|
||||||
, Param $ tmp ++ "/"
|
, Param $ tmp ++ "/"
|
||||||
|
@ -244,6 +243,8 @@ setupRepo gcryptid r
|
||||||
usablegitannexshell = either (const False) (const True)
|
usablegitannexshell = either (const False) (const True)
|
||||||
<$> Ssh.onRemote r (Git.Config.fromPipe r, Left undefined) "configlist" [] []
|
<$> Ssh.onRemote r (Git.Config.fromPipe r, Left undefined) "configlist" [] []
|
||||||
|
|
||||||
|
denyNonFastForwards = "receive.denyNonFastForwards"
|
||||||
|
|
||||||
shellOrRsync :: Remote -> Annex a -> Annex a -> Annex a
|
shellOrRsync :: Remote -> Annex a -> Annex a -> Annex a
|
||||||
shellOrRsync r ashell arsync = case method of
|
shellOrRsync r ashell arsync = case method of
|
||||||
AccessShell -> ashell
|
AccessShell -> ashell
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -28,6 +28,8 @@ git-annex (4.20130921) UNRELEASED; urgency=low
|
||||||
written by MacGPG.
|
written by MacGPG.
|
||||||
* assistant: More robust inotify handling; avoid crashing if a directory
|
* assistant: More robust inotify handling; avoid crashing if a directory
|
||||||
cannot be read.
|
cannot be read.
|
||||||
|
* Disable receive.denyNonFastForwards when setting up a gcrypt special
|
||||||
|
remote, since gcrypt needs to be able to fast-forward the master branch.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sun, 22 Sep 2013 19:42:29 -0400
|
-- Joey Hess <joeyh@debian.org> Sun, 22 Sep 2013 19:42:29 -0400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue