init: Fix a failure when used in a submodule on a crippled filesystem.
When the submodule's parent repo has an adjusted unlocked branch, it gets cloned by git, but git checks out master. git annex init then fails because it wants to enter the adjusted branch, but: adjusted branch adjusted/master(unlocked) already exists. Aborting because that branch may have changes that have not yet reached master Note that init actually then exits 0, leaving master checked out. This could also happen, absent submodules, if the parent repo has an adjusted unlocked branch, but it is not checked out. In the more common case where that branch is checked out, the clone uses the same branch, so no problem. The choices to fix this: * Init could delete the existing adjusted branch, and re-adjust. But then running init inside an adjusted branch on a crippled filesystem would lose any changes that have not been synced back to master. * Init could sync any changes back to master, but that would be very surprising behavior for it. * Init could simply check out the existing adjusted branch. If the branch is diverged from master, well, sync will sort that out later. This mirrors the behavior of cloning a repo that has an adjusted branch checked out that has not yet been synced back to master. Picked this choice.
This commit is contained in:
parent
41b1607aec
commit
5db79339a1
2 changed files with 22 additions and 3 deletions
|
@ -227,15 +227,28 @@ adjustToCrippledFileSystem :: Annex ()
|
|||
adjustToCrippledFileSystem = do
|
||||
warning "Entering an adjusted branch where files are unlocked as this filesystem does not support locked files."
|
||||
checkVersionSupported
|
||||
whenM (isNothing <$> originalBranch) $
|
||||
whenM (isNothing <$> inRepo Git.Branch.current) $
|
||||
void $ inRepo $ Git.Branch.commitCommand Git.Branch.AutomaticCommit
|
||||
[ Param "--quiet"
|
||||
, Param "--allow-empty"
|
||||
, Param "-m"
|
||||
, Param "commit before entering adjusted unlocked branch"
|
||||
]
|
||||
unlessM (enterAdjustedBranch (LinkAdjustment UnlockAdjustment)) $
|
||||
warning "Failed to enter adjusted branch!"
|
||||
inRepo Git.Branch.current >>= \case
|
||||
Just currbranch -> case getAdjustment currbranch of
|
||||
Just curradj | curradj == adj -> return ()
|
||||
_ -> do
|
||||
let adjbranch = originalToAdjusted currbranch adj
|
||||
ifM (inRepo (Git.Ref.exists $ adjBranch adjbranch))
|
||||
( unlessM (checkoutAdjustedBranch adjbranch []) $
|
||||
failedenter
|
||||
, unlessM (enterAdjustedBranch adj) $
|
||||
failedenter
|
||||
)
|
||||
Nothing -> failedenter
|
||||
where
|
||||
adj = LinkAdjustment UnlockAdjustment
|
||||
failedenter = warning "Failed to enter adjusted branch!"
|
||||
|
||||
setBasisBranch :: BasisBranch -> Ref -> Annex ()
|
||||
setBasisBranch (BasisBranch basis) new =
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
git-annex (7.20191018) UNRELEASED; urgency=medium
|
||||
|
||||
* init: Fix a failure when used in a submodule on a crippled filesystem.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Mon, 21 Oct 2019 11:01:06 -0400
|
||||
|
||||
git-annex (7.20191017) upstream; urgency=medium
|
||||
|
||||
* initremote: Added --sameas option, allows for two special remotes that
|
||||
|
|
Loading…
Reference in a new issue