adjust: If the adjusted branch already exists, avoid overwriting it, since it might contain changes that have not yet been propigated to the original branch.
Could not think of a foolproof way to detect if the old adjusted branch was just behind the current branch. It's possible that the user amended the adjusting commit at the head of the adjusted branch, for example. I decided to bail in this situation, instead of just entering the old branch, so that if git annex adjust succeeds the user is always in a *current* adjusted branch, not some old and out of date one. What could perhaps be done is enter the old branch and then update it. But that seems too magical; the user may have rebased master or something or may not want to propigate the changes from the old branch. Best to error out.
This commit is contained in:
parent
36cf163321
commit
9f05be393e
3 changed files with 37 additions and 14 deletions
|
@ -160,21 +160,41 @@ originalBranch = fmap fromAdjustedBranch <$> inRepo Git.Branch.current
|
||||||
- adjusted version of a branch, changes the adjustment of the original
|
- adjusted version of a branch, changes the adjustment of the original
|
||||||
- branch).
|
- branch).
|
||||||
-
|
-
|
||||||
- Can fail, if no branch is checked out, or perhaps if staged changes
|
- Can fail, if no branch is checked out, or if the adjusted branch already
|
||||||
- conflict with the adjusted branch.
|
- exists, or perhaps if staged changes conflict with the adjusted branch.
|
||||||
-}
|
-}
|
||||||
enterAdjustedBranch :: Adjustment -> Annex ()
|
enterAdjustedBranch :: Adjustment -> Annex Bool
|
||||||
enterAdjustedBranch adj = go =<< originalBranch
|
enterAdjustedBranch adj = go =<< originalBranch
|
||||||
where
|
where
|
||||||
go (Just origbranch) = do
|
go (Just origbranch) = do
|
||||||
AdjBranch b <- preventCommits $ const $
|
let adjbranch = adjBranch $ originalToAdjusted origbranch adj
|
||||||
adjustBranch adj origbranch
|
ifM (inRepo $ Git.Ref.exists adjbranch)
|
||||||
showOutput -- checkout can have output in large repos
|
( do
|
||||||
inRepo $ Git.Command.run
|
mapM_ (warning . unwords)
|
||||||
[ Param "checkout"
|
[ [ "adjusted branch"
|
||||||
, Param $ fromRef $ Git.Ref.base b
|
, Git.Ref.describe adjbranch
|
||||||
]
|
, "already exists."
|
||||||
go Nothing = error "not on any branch!"
|
]
|
||||||
|
, [ "Aborting because that branch may have changes that have not yet reached"
|
||||||
|
, Git.Ref.describe origbranch
|
||||||
|
]
|
||||||
|
, [ "You can check out the adjusted branch manually to enter it,"
|
||||||
|
, "or delete the adjusted branch and re-run this command."
|
||||||
|
]
|
||||||
|
]
|
||||||
|
return False
|
||||||
|
, do
|
||||||
|
AdjBranch b <- preventCommits $ const $
|
||||||
|
adjustBranch adj origbranch
|
||||||
|
showOutput -- checkout can have output in large repos
|
||||||
|
inRepo $ Git.Command.runBool
|
||||||
|
[ Param "checkout"
|
||||||
|
, Param $ fromRef $ Git.Ref.base b
|
||||||
|
]
|
||||||
|
)
|
||||||
|
go Nothing = do
|
||||||
|
warning "not on any branch!"
|
||||||
|
return False
|
||||||
|
|
||||||
adjustToCrippledFileSystem :: Annex ()
|
adjustToCrippledFileSystem :: Annex ()
|
||||||
adjustToCrippledFileSystem = do
|
adjustToCrippledFileSystem = do
|
||||||
|
@ -186,7 +206,8 @@ adjustToCrippledFileSystem = do
|
||||||
, Param "-m"
|
, Param "-m"
|
||||||
, Param "commit before entering adjusted unlocked branch"
|
, Param "commit before entering adjusted unlocked branch"
|
||||||
]
|
]
|
||||||
enterAdjustedBranch UnlockAdjustment
|
unlessM (enterAdjustedBranch UnlockAdjustment) $
|
||||||
|
warning "Failed to enter adjusted branch!"
|
||||||
|
|
||||||
setBasisBranch :: BasisBranch -> Ref -> Annex ()
|
setBasisBranch :: BasisBranch -> Ref -> Annex ()
|
||||||
setBasisBranch (BasisBranch basis) new =
|
setBasisBranch (BasisBranch basis) new =
|
||||||
|
|
|
@ -35,5 +35,4 @@ start :: Adjustment -> CommandStart
|
||||||
start adj = do
|
start adj = do
|
||||||
checkVersionSupported
|
checkVersionSupported
|
||||||
showStart "adjust" ""
|
showStart "adjust" ""
|
||||||
enterAdjustedBranch adj
|
next $ next $ enterAdjustedBranch adj
|
||||||
next $ next $ return True
|
|
||||||
|
|
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -3,6 +3,9 @@ git-annex (6.20160512) UNRELEASED; urgency=medium
|
||||||
* Change git annex info remote encryption description to use wording
|
* Change git annex info remote encryption description to use wording
|
||||||
closer to what's used in initremote.
|
closer to what's used in initremote.
|
||||||
* webapp: Avoid confusing display of dead remotes.
|
* webapp: Avoid confusing display of dead remotes.
|
||||||
|
* adjust: If the adjusted branch already exists, avoid overwriting it,
|
||||||
|
since it might contain changes that have not yet been propigated to the
|
||||||
|
original branch.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Wed, 11 May 2016 16:08:38 -0400
|
-- Joey Hess <id@joeyh.name> Wed, 11 May 2016 16:08:38 -0400
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue