2016-03-11 20:00:14 +00:00
|
|
|
{- adjusted branch
|
2016-02-25 20:11:13 +00:00
|
|
|
-
|
2023-02-27 18:35:27 +00:00
|
|
|
- Copyright 2016-2023 Joey Hess <id@joeyh.name>
|
2016-02-25 20:11:13 +00:00
|
|
|
-
|
2018-10-18 16:51:20 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2016-02-25 20:11:13 +00:00
|
|
|
-}
|
|
|
|
|
2020-04-07 21:41:09 +00:00
|
|
|
{-# LANGUAGE BangPatterns, OverloadedStrings #-}
|
2016-04-06 19:33:29 +00:00
|
|
|
|
2016-02-29 19:04:03 +00:00
|
|
|
module Annex.AdjustedBranch (
|
|
|
|
Adjustment(..),
|
2018-10-18 16:51:20 +00:00
|
|
|
LinkAdjustment(..),
|
|
|
|
PresenceAdjustment(..),
|
2020-11-13 18:32:06 +00:00
|
|
|
LinkPresentAdjustment(..),
|
2018-10-19 19:17:48 +00:00
|
|
|
adjustmentHidesFiles,
|
2020-11-13 18:58:42 +00:00
|
|
|
adjustmentIsStable,
|
2016-02-29 19:04:03 +00:00
|
|
|
OrigBranch,
|
2016-04-09 19:10:26 +00:00
|
|
|
AdjBranch(..),
|
2016-03-03 20:19:09 +00:00
|
|
|
originalToAdjusted,
|
2016-02-29 19:04:03 +00:00
|
|
|
adjustedToOriginal,
|
2016-03-03 18:13:54 +00:00
|
|
|
fromAdjustedBranch,
|
2016-03-29 17:26:06 +00:00
|
|
|
getAdjustment,
|
2016-02-29 19:04:03 +00:00
|
|
|
enterAdjustedBranch,
|
2020-11-16 18:09:55 +00:00
|
|
|
adjustedBranchRefresh,
|
2020-11-16 19:13:48 +00:00
|
|
|
adjustedBranchRefreshFull,
|
2016-04-04 17:17:24 +00:00
|
|
|
adjustBranch,
|
2020-11-16 18:09:55 +00:00
|
|
|
adjustTree,
|
2016-03-29 17:52:13 +00:00
|
|
|
adjustToCrippledFileSystem,
|
2020-11-24 16:31:17 +00:00
|
|
|
commitForAdjustedBranch,
|
2016-03-03 18:13:54 +00:00
|
|
|
propigateAdjustedCommits,
|
2020-11-16 18:09:55 +00:00
|
|
|
propigateAdjustedCommits',
|
|
|
|
commitAdjustedTree,
|
|
|
|
commitAdjustedTree',
|
|
|
|
BasisBranch(..),
|
|
|
|
basisBranch,
|
|
|
|
setBasisBranch,
|
|
|
|
preventCommits,
|
2016-06-02 19:58:22 +00:00
|
|
|
AdjustedClone(..),
|
2016-04-04 17:51:42 +00:00
|
|
|
checkAdjustedClone,
|
2016-04-22 16:29:32 +00:00
|
|
|
checkVersionSupported,
|
2018-12-03 16:57:23 +00:00
|
|
|
isGitVersionSupported,
|
2016-02-29 19:04:03 +00:00
|
|
|
) where
|
2016-02-25 20:11:13 +00:00
|
|
|
|
|
|
|
import Annex.Common
|
2018-10-19 19:17:48 +00:00
|
|
|
import Types.AdjustedBranch
|
|
|
|
import Annex.AdjustedBranch.Name
|
2016-02-25 20:11:13 +00:00
|
|
|
import qualified Annex
|
2016-03-03 20:19:09 +00:00
|
|
|
import Git
|
2016-02-25 20:11:13 +00:00
|
|
|
import Git.Types
|
|
|
|
import qualified Git.Branch
|
|
|
|
import qualified Git.Ref
|
|
|
|
import qualified Git.Command
|
2016-03-03 20:19:09 +00:00
|
|
|
import qualified Git.Tree
|
2016-03-11 20:00:14 +00:00
|
|
|
import qualified Git.DiffTree
|
2016-03-03 20:19:09 +00:00
|
|
|
import Git.Tree (TreeItem(..))
|
2016-03-11 20:00:14 +00:00
|
|
|
import Git.Sha
|
2016-02-25 20:11:13 +00:00
|
|
|
import Git.Env
|
2016-03-03 16:55:00 +00:00
|
|
|
import Git.Index
|
2016-03-03 20:19:09 +00:00
|
|
|
import Git.FilePath
|
2016-03-03 16:55:00 +00:00
|
|
|
import qualified Git.LockFile
|
2016-04-22 16:29:32 +00:00
|
|
|
import qualified Git.Version
|
2016-02-25 20:11:13 +00:00
|
|
|
import Annex.CatFile
|
|
|
|
import Annex.Link
|
2020-11-16 18:09:55 +00:00
|
|
|
import Annex.Content.Presence
|
|
|
|
import Annex.CurrentBranch
|
|
|
|
import Types.CleanupActions
|
2016-02-29 21:27:19 +00:00
|
|
|
import qualified Database.Keys
|
2016-06-02 21:02:38 +00:00
|
|
|
import Config
|
2023-02-27 18:35:27 +00:00
|
|
|
import Logs.View (is_branchView)
|
sync: use log to track adjusted branch needs updating
Speeds up sync in an adjusted branch by avoiding re-adjusting the branch
unncessarily, particularly when it is adjusted with --hide-missing or
--unlock-present.
When there are a lot of files, that was the majority of the time of a
--no-content sync.
Uses a log file, which is updated when content presence changes. This
adds a little bit of overhead to every file get/drop when on such an
adjusted branch. The overhead is minimal for get of any size of file,
but might be noticable for drop in some cases. It seems like a reasonable
trade-off. It would be possible to update the log file only at the end, but
then it would not happen if the command is interrupted.
When not in an adjusted branch, there should be no additional overhead.
(getCurrentBranch is an MVar read, and it avoids the MVar read of
getGitConfig.)
Note that this does not deal with situations such as:
git checkout master, git-annex get, git checkout adjusted branch,
git-annex sync. The sync won't know that the adjusted branch needs to be
updated. Dealing with that would add overhead to operation in non-adjusted
branches, which I don't like. Also, there are other situations like having
two adjusted branches that both need to be updated like this, and switching
between them and sync not updating.
This does mean a behavior change to sync, since it did previously deal
with those situations. But, the documentation did not say that it did.
The man pages only talk about sync updating the adjusted branch after
it transfers content.
I did consider making sync keep track of content it transferred (and
dropped) and only update the adjusted branch then, not to catch up to other
changes made previously. That would perform better. But it seemed rather
hard to implement, and also it would have problems with races with a
concurrent get/drop, which this implementation avoids.
And it seemed pretty likely someone had gotten used to get/drop followed by
sync updating the branch. It seems much less likely someone is switching
branches, doing get/drop, and then switching back and expecting sync to update
the branch.
Re-running git-annex adjust still does a full re-adjusting of the branch,
for anyone who needs that.
Sponsored-by: Leon Schuermann on Patreon
2023-06-08 18:35:26 +00:00
|
|
|
import Logs.AdjustedBranchUpdate
|
2016-02-25 20:11:13 +00:00
|
|
|
|
sync: use log to track adjusted branch needs updating
Speeds up sync in an adjusted branch by avoiding re-adjusting the branch
unncessarily, particularly when it is adjusted with --hide-missing or
--unlock-present.
When there are a lot of files, that was the majority of the time of a
--no-content sync.
Uses a log file, which is updated when content presence changes. This
adds a little bit of overhead to every file get/drop when on such an
adjusted branch. The overhead is minimal for get of any size of file,
but might be noticable for drop in some cases. It seems like a reasonable
trade-off. It would be possible to update the log file only at the end, but
then it would not happen if the command is interrupted.
When not in an adjusted branch, there should be no additional overhead.
(getCurrentBranch is an MVar read, and it avoids the MVar read of
getGitConfig.)
Note that this does not deal with situations such as:
git checkout master, git-annex get, git checkout adjusted branch,
git-annex sync. The sync won't know that the adjusted branch needs to be
updated. Dealing with that would add overhead to operation in non-adjusted
branches, which I don't like. Also, there are other situations like having
two adjusted branches that both need to be updated like this, and switching
between them and sync not updating.
This does mean a behavior change to sync, since it did previously deal
with those situations. But, the documentation did not say that it did.
The man pages only talk about sync updating the adjusted branch after
it transfers content.
I did consider making sync keep track of content it transferred (and
dropped) and only update the adjusted branch then, not to catch up to other
changes made previously. That would perform better. But it seemed rather
hard to implement, and also it would have problems with races with a
concurrent get/drop, which this implementation avoids.
And it seemed pretty likely someone had gotten used to get/drop followed by
sync updating the branch. It seems much less likely someone is switching
branches, doing get/drop, and then switching back and expecting sync to update
the branch.
Re-running git-annex adjust still does a full re-adjusting of the branch,
for anyone who needs that.
Sponsored-by: Leon Schuermann on Patreon
2023-06-08 18:35:26 +00:00
|
|
|
import Data.Time.Clock.POSIX
|
2016-03-11 20:00:14 +00:00
|
|
|
import qualified Data.Map as M
|
|
|
|
|
2018-10-18 16:51:20 +00:00
|
|
|
class AdjustTreeItem t where
|
2020-11-13 18:58:42 +00:00
|
|
|
-- How to perform various adjustments to a TreeItem.
|
2018-10-18 16:51:20 +00:00
|
|
|
adjustTreeItem :: t -> TreeItem -> Annex (Maybe TreeItem)
|
2020-11-13 18:58:42 +00:00
|
|
|
-- Will adjusting a given tree always yield the same adjusted tree?
|
|
|
|
adjustmentIsStable :: t -> Bool
|
2018-10-18 16:51:20 +00:00
|
|
|
|
|
|
|
instance AdjustTreeItem Adjustment where
|
|
|
|
adjustTreeItem (LinkAdjustment l) t = adjustTreeItem l t
|
|
|
|
adjustTreeItem (PresenceAdjustment p Nothing) t = adjustTreeItem p t
|
|
|
|
adjustTreeItem (PresenceAdjustment p (Just l)) t =
|
|
|
|
adjustTreeItem p t >>= \case
|
|
|
|
Nothing -> return Nothing
|
|
|
|
Just t' -> adjustTreeItem l t'
|
2020-11-13 18:32:06 +00:00
|
|
|
adjustTreeItem (LinkPresentAdjustment l) t = adjustTreeItem l t
|
2018-10-18 16:51:20 +00:00
|
|
|
|
2020-11-13 18:58:42 +00:00
|
|
|
adjustmentIsStable (LinkAdjustment l) = adjustmentIsStable l
|
|
|
|
adjustmentIsStable (PresenceAdjustment p _) = adjustmentIsStable p
|
|
|
|
adjustmentIsStable (LinkPresentAdjustment l) = adjustmentIsStable l
|
|
|
|
|
2018-10-18 16:51:20 +00:00
|
|
|
instance AdjustTreeItem LinkAdjustment where
|
2020-11-13 17:27:03 +00:00
|
|
|
adjustTreeItem UnlockAdjustment =
|
|
|
|
ifSymlink adjustToPointer noAdjust
|
|
|
|
adjustTreeItem LockAdjustment =
|
|
|
|
ifSymlink noAdjust adjustToSymlink
|
|
|
|
adjustTreeItem FixAdjustment =
|
|
|
|
ifSymlink adjustToSymlink noAdjust
|
|
|
|
adjustTreeItem UnFixAdjustment =
|
|
|
|
ifSymlink (adjustToSymlink' gitAnnexLinkCanonical) noAdjust
|
2020-11-13 18:58:42 +00:00
|
|
|
|
|
|
|
adjustmentIsStable _ = True
|
2018-10-18 16:51:20 +00:00
|
|
|
|
|
|
|
instance AdjustTreeItem PresenceAdjustment where
|
2020-11-13 17:27:03 +00:00
|
|
|
adjustTreeItem HideMissingAdjustment =
|
|
|
|
ifPresent noAdjust hideAdjust
|
|
|
|
adjustTreeItem ShowMissingAdjustment =
|
|
|
|
noAdjust
|
|
|
|
|
2020-11-13 18:58:42 +00:00
|
|
|
adjustmentIsStable HideMissingAdjustment = False
|
|
|
|
adjustmentIsStable ShowMissingAdjustment = True
|
|
|
|
|
2020-11-13 18:32:06 +00:00
|
|
|
instance AdjustTreeItem LinkPresentAdjustment where
|
|
|
|
adjustTreeItem UnlockPresentAdjustment =
|
2020-11-13 17:27:03 +00:00
|
|
|
ifPresent adjustToPointer adjustToSymlink
|
2020-11-13 18:32:06 +00:00
|
|
|
adjustTreeItem LockPresentAdjustment =
|
|
|
|
-- Turn all pointers back to symlinks, whether the content
|
|
|
|
-- is present or not. This is done because the content
|
|
|
|
-- availability may have changed and the branch not been
|
|
|
|
-- re-adjusted to keep up, so there may be pointers whose
|
|
|
|
-- content is not present.
|
|
|
|
ifSymlink noAdjust adjustToSymlink
|
2020-11-13 17:27:03 +00:00
|
|
|
|
2020-11-13 18:58:42 +00:00
|
|
|
adjustmentIsStable UnlockPresentAdjustment = False
|
|
|
|
adjustmentIsStable LockPresentAdjustment = True
|
|
|
|
|
2020-11-13 17:27:03 +00:00
|
|
|
ifSymlink
|
|
|
|
:: (TreeItem -> Annex a)
|
|
|
|
-> (TreeItem -> Annex a)
|
|
|
|
-> TreeItem
|
|
|
|
-> Annex a
|
2016-05-16 21:05:42 +00:00
|
|
|
ifSymlink issymlink notsymlink ti@(TreeItem _f m _s)
|
2018-05-14 18:22:44 +00:00
|
|
|
| toTreeItemType m == Just TreeSymlink = issymlink ti
|
2016-05-16 21:05:42 +00:00
|
|
|
| otherwise = notsymlink ti
|
|
|
|
|
2020-11-13 17:27:03 +00:00
|
|
|
ifPresent
|
|
|
|
:: (TreeItem -> Annex (Maybe TreeItem))
|
|
|
|
-> (TreeItem -> Annex (Maybe TreeItem))
|
|
|
|
-> TreeItem
|
|
|
|
-> Annex (Maybe TreeItem)
|
|
|
|
ifPresent ispresent notpresent ti@(TreeItem _ _ s) =
|
|
|
|
catKey s >>= \case
|
|
|
|
Just k -> ifM (inAnnex k) (ispresent ti, notpresent ti)
|
|
|
|
Nothing -> return (Just ti)
|
|
|
|
|
2016-05-16 21:05:42 +00:00
|
|
|
noAdjust :: TreeItem -> Annex (Maybe TreeItem)
|
|
|
|
noAdjust = return . Just
|
|
|
|
|
2020-11-13 17:27:03 +00:00
|
|
|
hideAdjust :: TreeItem -> Annex (Maybe TreeItem)
|
|
|
|
hideAdjust _ = return Nothing
|
|
|
|
|
2016-05-16 21:05:42 +00:00
|
|
|
adjustToPointer :: TreeItem -> Annex (Maybe TreeItem)
|
2017-11-15 20:55:38 +00:00
|
|
|
adjustToPointer ti@(TreeItem f _m s) = catKey s >>= \case
|
|
|
|
Just k -> do
|
|
|
|
Database.Keys.addAssociatedFile k f
|
2018-05-14 18:22:44 +00:00
|
|
|
Just . TreeItem f (fromTreeItemType TreeFile)
|
2017-11-15 20:55:38 +00:00
|
|
|
<$> hashPointerFile k
|
|
|
|
Nothing -> return (Just ti)
|
2016-05-16 21:05:42 +00:00
|
|
|
|
|
|
|
adjustToSymlink :: TreeItem -> Annex (Maybe TreeItem)
|
|
|
|
adjustToSymlink = adjustToSymlink' gitAnnexLink
|
|
|
|
|
2020-10-30 17:31:35 +00:00
|
|
|
adjustToSymlink' :: (RawFilePath -> Key -> Git.Repo -> GitConfig -> IO RawFilePath) -> TreeItem -> Annex (Maybe TreeItem)
|
2017-11-15 20:55:38 +00:00
|
|
|
adjustToSymlink' gitannexlink ti@(TreeItem f _m s) = catKey s >>= \case
|
|
|
|
Just k -> do
|
2020-10-30 17:31:35 +00:00
|
|
|
absf <- inRepo $ \r -> absPath $ fromTopFilePath f r
|
2017-11-15 20:55:38 +00:00
|
|
|
linktarget <- calcRepo $ gitannexlink absf k
|
2018-05-14 18:22:44 +00:00
|
|
|
Just . TreeItem f (fromTreeItemType TreeSymlink)
|
2017-11-15 20:55:38 +00:00
|
|
|
<$> hashSymlink linktarget
|
|
|
|
Nothing -> return (Just ti)
|
2016-02-25 20:11:13 +00:00
|
|
|
|
2016-04-09 18:12:25 +00:00
|
|
|
-- This is a hidden branch ref, that's used as the basis for the AdjBranch,
|
|
|
|
-- since pushes can overwrite the OrigBranch at any time. So, changes
|
|
|
|
-- are propigated from the AdjBranch to the head of the BasisBranch.
|
|
|
|
newtype BasisBranch = BasisBranch Ref
|
|
|
|
|
|
|
|
-- The basis for refs/heads/adjusted/master(unlocked) is
|
2016-04-09 18:17:20 +00:00
|
|
|
-- refs/basis/adjusted/master(unlocked).
|
2016-04-09 18:12:25 +00:00
|
|
|
basisBranch :: AdjBranch -> BasisBranch
|
2016-04-09 19:10:26 +00:00
|
|
|
basisBranch (AdjBranch adjbranch) = BasisBranch $
|
2020-04-07 21:41:09 +00:00
|
|
|
Ref ("refs/basis/" <> fromRef' (Git.Ref.base adjbranch))
|
2016-04-09 18:12:25 +00:00
|
|
|
|
2016-03-29 17:26:06 +00:00
|
|
|
getAdjustment :: Branch -> Maybe Adjustment
|
|
|
|
getAdjustment = fmap fst . adjustedToOriginal
|
|
|
|
|
2016-04-09 19:10:26 +00:00
|
|
|
fromAdjustedBranch :: Branch -> OrigBranch
|
2016-03-03 18:13:54 +00:00
|
|
|
fromAdjustedBranch b = maybe b snd (adjustedToOriginal b)
|
|
|
|
|
2016-02-25 20:11:13 +00:00
|
|
|
{- Enter an adjusted version of current branch (or, if already in an
|
|
|
|
- adjusted version of a branch, changes the adjustment of the original
|
2016-04-09 18:12:25 +00:00
|
|
|
- branch).
|
2016-02-25 20:11:13 +00:00
|
|
|
-
|
2016-05-13 18:04:22 +00:00
|
|
|
- Can fail, if no branch is checked out, or if the adjusted branch already
|
2018-10-18 19:32:42 +00:00
|
|
|
- exists, or if staged changes prevent a checkout.
|
2016-02-25 20:11:13 +00:00
|
|
|
-}
|
2016-05-13 18:04:22 +00:00
|
|
|
enterAdjustedBranch :: Adjustment -> Annex Bool
|
2018-10-18 19:32:42 +00:00
|
|
|
enterAdjustedBranch adj = inRepo Git.Branch.current >>= \case
|
|
|
|
Just currbranch -> case getAdjustment currbranch of
|
|
|
|
Just curradj | curradj == adj ->
|
2018-10-20 18:12:04 +00:00
|
|
|
updateAdjustedBranch adj (AdjBranch currbranch)
|
2018-10-18 19:32:42 +00:00
|
|
|
(fromAdjustedBranch currbranch)
|
|
|
|
_ -> go currbranch
|
|
|
|
Nothing -> do
|
|
|
|
warning "not on any branch!"
|
|
|
|
return False
|
2016-02-25 20:11:13 +00:00
|
|
|
where
|
2018-10-18 19:32:42 +00:00
|
|
|
go currbranch = do
|
|
|
|
let origbranch = fromAdjustedBranch currbranch
|
2016-05-13 18:04:22 +00:00
|
|
|
let adjbranch = adjBranch $ originalToAdjusted origbranch adj
|
2023-02-27 18:35:27 +00:00
|
|
|
ifM (inRepo (Git.Ref.exists adjbranch) <&&> (not <$> Annex.getRead Annex.force) <&&> pure (not (is_branchView origbranch)))
|
2016-05-13 18:04:22 +00:00
|
|
|
( do
|
filter out control characters in warning messages
Converted warning and similar to use StringContainingQuotedPath. Most
warnings are static strings, some do refer to filepaths that need to be
quoted, and others don't need quoting.
Note that, since quote filters out control characters of even
UnquotedString, this makes all warnings safe, even when an attacker
sneaks in a control character in some other way.
When json is being output, no quoting is done, since json gets its own
quoting.
This does, as a side effect, make warning messages in json output not
be indented. The indentation is only needed to offset warning messages
underneath the display of the file they apply to, so that's ok.
Sponsored-by: Brett Eisenberg on Patreon
2023-04-10 18:47:32 +00:00
|
|
|
mapM_ (warning . UnquotedString . unwords)
|
2016-05-13 18:04:22 +00:00
|
|
|
[ [ "adjusted branch"
|
|
|
|
, Git.Ref.describe adjbranch
|
|
|
|
, "already exists."
|
|
|
|
]
|
|
|
|
, [ "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,"
|
2018-10-20 15:53:35 +00:00
|
|
|
, "or add the --force option to overwrite the old branch."
|
2016-05-13 18:04:22 +00:00
|
|
|
]
|
|
|
|
]
|
|
|
|
return False
|
|
|
|
, do
|
sync: use log to track adjusted branch needs updating
Speeds up sync in an adjusted branch by avoiding re-adjusting the branch
unncessarily, particularly when it is adjusted with --hide-missing or
--unlock-present.
When there are a lot of files, that was the majority of the time of a
--no-content sync.
Uses a log file, which is updated when content presence changes. This
adds a little bit of overhead to every file get/drop when on such an
adjusted branch. The overhead is minimal for get of any size of file,
but might be noticable for drop in some cases. It seems like a reasonable
trade-off. It would be possible to update the log file only at the end, but
then it would not happen if the command is interrupted.
When not in an adjusted branch, there should be no additional overhead.
(getCurrentBranch is an MVar read, and it avoids the MVar read of
getGitConfig.)
Note that this does not deal with situations such as:
git checkout master, git-annex get, git checkout adjusted branch,
git-annex sync. The sync won't know that the adjusted branch needs to be
updated. Dealing with that would add overhead to operation in non-adjusted
branches, which I don't like. Also, there are other situations like having
two adjusted branches that both need to be updated like this, and switching
between them and sync not updating.
This does mean a behavior change to sync, since it did previously deal
with those situations. But, the documentation did not say that it did.
The man pages only talk about sync updating the adjusted branch after
it transfers content.
I did consider making sync keep track of content it transferred (and
dropped) and only update the adjusted branch then, not to catch up to other
changes made previously. That would perform better. But it seemed rather
hard to implement, and also it would have problems with races with a
concurrent get/drop, which this implementation avoids.
And it seemed pretty likely someone had gotten used to get/drop followed by
sync updating the branch. It seems much less likely someone is switching
branches, doing get/drop, and then switching back and expecting sync to update
the branch.
Re-running git-annex adjust still does a full re-adjusting of the branch,
for anyone who needs that.
Sponsored-by: Leon Schuermann on Patreon
2023-06-08 18:35:26 +00:00
|
|
|
starttime <- liftIO getPOSIXTime
|
2018-10-18 19:32:42 +00:00
|
|
|
b <- preventCommits $ const $
|
2016-05-13 18:04:22 +00:00
|
|
|
adjustBranch adj origbranch
|
sync: use log to track adjusted branch needs updating
Speeds up sync in an adjusted branch by avoiding re-adjusting the branch
unncessarily, particularly when it is adjusted with --hide-missing or
--unlock-present.
When there are a lot of files, that was the majority of the time of a
--no-content sync.
Uses a log file, which is updated when content presence changes. This
adds a little bit of overhead to every file get/drop when on such an
adjusted branch. The overhead is minimal for get of any size of file,
but might be noticable for drop in some cases. It seems like a reasonable
trade-off. It would be possible to update the log file only at the end, but
then it would not happen if the command is interrupted.
When not in an adjusted branch, there should be no additional overhead.
(getCurrentBranch is an MVar read, and it avoids the MVar read of
getGitConfig.)
Note that this does not deal with situations such as:
git checkout master, git-annex get, git checkout adjusted branch,
git-annex sync. The sync won't know that the adjusted branch needs to be
updated. Dealing with that would add overhead to operation in non-adjusted
branches, which I don't like. Also, there are other situations like having
two adjusted branches that both need to be updated like this, and switching
between them and sync not updating.
This does mean a behavior change to sync, since it did previously deal
with those situations. But, the documentation did not say that it did.
The man pages only talk about sync updating the adjusted branch after
it transfers content.
I did consider making sync keep track of content it transferred (and
dropped) and only update the adjusted branch then, not to catch up to other
changes made previously. That would perform better. But it seemed rather
hard to implement, and also it would have problems with races with a
concurrent get/drop, which this implementation avoids.
And it seemed pretty likely someone had gotten used to get/drop followed by
sync updating the branch. It seems much less likely someone is switching
branches, doing get/drop, and then switching back and expecting sync to update
the branch.
Re-running git-annex adjust still does a full re-adjusting of the branch,
for anyone who needs that.
Sponsored-by: Leon Schuermann on Patreon
2023-06-08 18:35:26 +00:00
|
|
|
ok <- checkoutAdjustedBranch b False
|
|
|
|
when ok $
|
|
|
|
recordAdjustedBranchUpdateFinished starttime
|
|
|
|
return ok
|
2016-05-13 18:04:22 +00:00
|
|
|
)
|
2018-10-18 19:32:42 +00:00
|
|
|
|
2020-11-16 18:31:02 +00:00
|
|
|
checkoutAdjustedBranch :: AdjBranch -> Bool -> Annex Bool
|
|
|
|
checkoutAdjustedBranch (AdjBranch b) quietcheckout = do
|
|
|
|
-- checkout can have output in large repos
|
|
|
|
unless quietcheckout
|
|
|
|
showOutput
|
2018-10-18 19:32:42 +00:00
|
|
|
inRepo $ Git.Command.runBool $
|
|
|
|
[ Param "checkout"
|
|
|
|
, Param $ fromRef $ Git.Ref.base b
|
2020-11-16 18:31:02 +00:00
|
|
|
, if quietcheckout then Param "--quiet" else Param "--progress"
|
|
|
|
]
|
2018-10-18 19:32:42 +00:00
|
|
|
|
|
|
|
{- Already in a branch with this adjustment, but the user asked to enter it
|
2020-11-13 18:58:42 +00:00
|
|
|
- again. This should have the same result as propagating any commits
|
|
|
|
- back to the original branch, checking out the original branch, deleting
|
|
|
|
- and rebuilding the adjusted branch, and then checking it out.
|
2018-10-18 19:32:42 +00:00
|
|
|
- But, it can be implemented more efficiently than that.
|
|
|
|
-}
|
2018-10-20 18:12:04 +00:00
|
|
|
updateAdjustedBranch :: Adjustment -> AdjBranch -> OrigBranch -> Annex Bool
|
2020-11-13 18:58:42 +00:00
|
|
|
updateAdjustedBranch adj (AdjBranch currbranch) origbranch
|
|
|
|
| not (adjustmentIsStable adj) = do
|
2023-03-23 20:36:43 +00:00
|
|
|
(b, origheadfile, newheadfile) <- preventCommits $ \commitlck -> do
|
2020-11-13 18:58:42 +00:00
|
|
|
-- Avoid losing any commits that the adjusted branch
|
|
|
|
-- has that have not yet been propigated back to the
|
|
|
|
-- origbranch.
|
|
|
|
_ <- propigateAdjustedCommits' origbranch adj commitlck
|
2023-04-04 18:25:01 +00:00
|
|
|
|
|
|
|
origheadfile <- inRepo $ readFileStrict . Git.Ref.headFile
|
2023-06-08 17:33:58 +00:00
|
|
|
origheadsha <- inRepo (Git.Ref.sha currbranch)
|
|
|
|
|
|
|
|
b <- adjustBranch adj origbranch
|
2018-10-18 19:32:42 +00:00
|
|
|
|
2020-11-13 18:58:42 +00:00
|
|
|
-- Git normally won't do anything when asked to check
|
|
|
|
-- out the currently checked out branch, even when its
|
|
|
|
-- ref has changed. Work around this by writing a raw
|
|
|
|
-- sha to .git/HEAD.
|
2023-06-08 17:33:58 +00:00
|
|
|
newheadfile <- case origheadsha of
|
|
|
|
Just s -> do
|
2023-03-23 20:36:43 +00:00
|
|
|
inRepo $ \r -> do
|
2023-06-08 17:33:58 +00:00
|
|
|
let newheadfile = fromRef s
|
2023-03-23 20:36:43 +00:00
|
|
|
writeFile (Git.Ref.headFile r) newheadfile
|
|
|
|
return (Just newheadfile)
|
|
|
|
_ -> return Nothing
|
2018-10-18 19:32:42 +00:00
|
|
|
|
2023-03-23 20:36:43 +00:00
|
|
|
return (b, origheadfile, newheadfile)
|
2018-10-18 19:32:42 +00:00
|
|
|
|
2020-11-13 18:58:42 +00:00
|
|
|
-- Make git checkout quiet to avoid warnings about
|
|
|
|
-- disconnected branch tips being lost.
|
2023-03-23 20:36:43 +00:00
|
|
|
ok <- checkoutAdjustedBranch b True
|
|
|
|
|
|
|
|
-- Avoid leaving repo with detached head.
|
|
|
|
unless ok $ case newheadfile of
|
|
|
|
Nothing -> noop
|
|
|
|
Just v -> preventCommits $ \_commitlck -> inRepo $ \r -> do
|
2023-04-04 18:25:01 +00:00
|
|
|
v' <- readFileStrict (Git.Ref.headFile r)
|
2023-03-23 20:36:43 +00:00
|
|
|
when (v == v') $
|
|
|
|
writeFile (Git.Ref.headFile r) origheadfile
|
|
|
|
|
|
|
|
return ok
|
2020-11-13 18:58:42 +00:00
|
|
|
| otherwise = preventCommits $ \commitlck -> do
|
|
|
|
-- Done for consistency.
|
|
|
|
_ <- propigateAdjustedCommits' origbranch adj commitlck
|
|
|
|
-- No need to actually update the branch because the
|
|
|
|
-- adjustment is stable.
|
|
|
|
return True
|
2016-02-25 20:11:13 +00:00
|
|
|
|
2020-11-16 18:09:55 +00:00
|
|
|
{- Passed an action that, if it succeeds may get or drop the Key associated
|
|
|
|
- with the file. When the adjusted branch needs to be refreshed to reflect
|
|
|
|
- those changes, it's handled here.
|
|
|
|
-
|
|
|
|
- Note that the AssociatedFile must be verified by this to point to the
|
|
|
|
- Key. In some cases, the value was provided by the user and might not
|
|
|
|
- really be an associated file.
|
|
|
|
-}
|
|
|
|
adjustedBranchRefresh :: AssociatedFile -> Annex a -> Annex a
|
|
|
|
adjustedBranchRefresh _af a = do
|
|
|
|
r <- a
|
sync: use log to track adjusted branch needs updating
Speeds up sync in an adjusted branch by avoiding re-adjusting the branch
unncessarily, particularly when it is adjusted with --hide-missing or
--unlock-present.
When there are a lot of files, that was the majority of the time of a
--no-content sync.
Uses a log file, which is updated when content presence changes. This
adds a little bit of overhead to every file get/drop when on such an
adjusted branch. The overhead is minimal for get of any size of file,
but might be noticable for drop in some cases. It seems like a reasonable
trade-off. It would be possible to update the log file only at the end, but
then it would not happen if the command is interrupted.
When not in an adjusted branch, there should be no additional overhead.
(getCurrentBranch is an MVar read, and it avoids the MVar read of
getGitConfig.)
Note that this does not deal with situations such as:
git checkout master, git-annex get, git checkout adjusted branch,
git-annex sync. The sync won't know that the adjusted branch needs to be
updated. Dealing with that would add overhead to operation in non-adjusted
branches, which I don't like. Also, there are other situations like having
two adjusted branches that both need to be updated like this, and switching
between them and sync not updating.
This does mean a behavior change to sync, since it did previously deal
with those situations. But, the documentation did not say that it did.
The man pages only talk about sync updating the adjusted branch after
it transfers content.
I did consider making sync keep track of content it transferred (and
dropped) and only update the adjusted branch then, not to catch up to other
changes made previously. That would perform better. But it seemed rather
hard to implement, and also it would have problems with races with a
concurrent get/drop, which this implementation avoids.
And it seemed pretty likely someone had gotten used to get/drop followed by
sync updating the branch. It seems much less likely someone is switching
branches, doing get/drop, and then switching back and expecting sync to update
the branch.
Re-running git-annex adjust still does a full re-adjusting of the branch,
for anyone who needs that.
Sponsored-by: Leon Schuermann on Patreon
2023-06-08 18:35:26 +00:00
|
|
|
go
|
2020-11-16 18:09:55 +00:00
|
|
|
return r
|
|
|
|
where
|
sync: use log to track adjusted branch needs updating
Speeds up sync in an adjusted branch by avoiding re-adjusting the branch
unncessarily, particularly when it is adjusted with --hide-missing or
--unlock-present.
When there are a lot of files, that was the majority of the time of a
--no-content sync.
Uses a log file, which is updated when content presence changes. This
adds a little bit of overhead to every file get/drop when on such an
adjusted branch. The overhead is minimal for get of any size of file,
but might be noticable for drop in some cases. It seems like a reasonable
trade-off. It would be possible to update the log file only at the end, but
then it would not happen if the command is interrupted.
When not in an adjusted branch, there should be no additional overhead.
(getCurrentBranch is an MVar read, and it avoids the MVar read of
getGitConfig.)
Note that this does not deal with situations such as:
git checkout master, git-annex get, git checkout adjusted branch,
git-annex sync. The sync won't know that the adjusted branch needs to be
updated. Dealing with that would add overhead to operation in non-adjusted
branches, which I don't like. Also, there are other situations like having
two adjusted branches that both need to be updated like this, and switching
between them and sync not updating.
This does mean a behavior change to sync, since it did previously deal
with those situations. But, the documentation did not say that it did.
The man pages only talk about sync updating the adjusted branch after
it transfers content.
I did consider making sync keep track of content it transferred (and
dropped) and only update the adjusted branch then, not to catch up to other
changes made previously. That would perform better. But it seemed rather
hard to implement, and also it would have problems with races with a
concurrent get/drop, which this implementation avoids.
And it seemed pretty likely someone had gotten used to get/drop followed by
sync updating the branch. It seems much less likely someone is switching
branches, doing get/drop, and then switching back and expecting sync to update
the branch.
Re-running git-annex adjust still does a full re-adjusting of the branch,
for anyone who needs that.
Sponsored-by: Leon Schuermann on Patreon
2023-06-08 18:35:26 +00:00
|
|
|
go = getCurrentBranch >>= \case
|
2020-11-16 18:09:55 +00:00
|
|
|
(Just origbranch, Just adj) ->
|
sync: use log to track adjusted branch needs updating
Speeds up sync in an adjusted branch by avoiding re-adjusting the branch
unncessarily, particularly when it is adjusted with --hide-missing or
--unlock-present.
When there are a lot of files, that was the majority of the time of a
--no-content sync.
Uses a log file, which is updated when content presence changes. This
adds a little bit of overhead to every file get/drop when on such an
adjusted branch. The overhead is minimal for get of any size of file,
but might be noticable for drop in some cases. It seems like a reasonable
trade-off. It would be possible to update the log file only at the end, but
then it would not happen if the command is interrupted.
When not in an adjusted branch, there should be no additional overhead.
(getCurrentBranch is an MVar read, and it avoids the MVar read of
getGitConfig.)
Note that this does not deal with situations such as:
git checkout master, git-annex get, git checkout adjusted branch,
git-annex sync. The sync won't know that the adjusted branch needs to be
updated. Dealing with that would add overhead to operation in non-adjusted
branches, which I don't like. Also, there are other situations like having
two adjusted branches that both need to be updated like this, and switching
between them and sync not updating.
This does mean a behavior change to sync, since it did previously deal
with those situations. But, the documentation did not say that it did.
The man pages only talk about sync updating the adjusted branch after
it transfers content.
I did consider making sync keep track of content it transferred (and
dropped) and only update the adjusted branch then, not to catch up to other
changes made previously. That would perform better. But it seemed rather
hard to implement, and also it would have problems with races with a
concurrent get/drop, which this implementation avoids.
And it seemed pretty likely someone had gotten used to get/drop followed by
sync updating the branch. It seems much less likely someone is switching
branches, doing get/drop, and then switching back and expecting sync to update
the branch.
Re-running git-annex adjust still does a full re-adjusting of the branch,
for anyone who needs that.
Sponsored-by: Leon Schuermann on Patreon
2023-06-08 18:35:26 +00:00
|
|
|
unless (adjustmentIsStable adj) $ do
|
|
|
|
recordAdjustedBranchUpdateNeeded
|
|
|
|
n <- annexAdjustedBranchRefresh <$> Annex.getGitConfig
|
|
|
|
unless (n == 0) $ ifM (checkcounter n)
|
|
|
|
-- This is slow, it would be better to incrementally
|
|
|
|
-- adjust the AssociatedFile, and only call this once
|
|
|
|
-- at shutdown to handle cases where not all
|
|
|
|
-- AssociatedFiles are known.
|
|
|
|
( adjustedBranchRefreshFull' adj origbranch
|
2020-12-11 19:28:58 +00:00
|
|
|
, Annex.addCleanupAction AdjustedBranchUpdate $
|
sync: use log to track adjusted branch needs updating
Speeds up sync in an adjusted branch by avoiding re-adjusting the branch
unncessarily, particularly when it is adjusted with --hide-missing or
--unlock-present.
When there are a lot of files, that was the majority of the time of a
--no-content sync.
Uses a log file, which is updated when content presence changes. This
adds a little bit of overhead to every file get/drop when on such an
adjusted branch. The overhead is minimal for get of any size of file,
but might be noticable for drop in some cases. It seems like a reasonable
trade-off. It would be possible to update the log file only at the end, but
then it would not happen if the command is interrupted.
When not in an adjusted branch, there should be no additional overhead.
(getCurrentBranch is an MVar read, and it avoids the MVar read of
getGitConfig.)
Note that this does not deal with situations such as:
git checkout master, git-annex get, git checkout adjusted branch,
git-annex sync. The sync won't know that the adjusted branch needs to be
updated. Dealing with that would add overhead to operation in non-adjusted
branches, which I don't like. Also, there are other situations like having
two adjusted branches that both need to be updated like this, and switching
between them and sync not updating.
This does mean a behavior change to sync, since it did previously deal
with those situations. But, the documentation did not say that it did.
The man pages only talk about sync updating the adjusted branch after
it transfers content.
I did consider making sync keep track of content it transferred (and
dropped) and only update the adjusted branch then, not to catch up to other
changes made previously. That would perform better. But it seemed rather
hard to implement, and also it would have problems with races with a
concurrent get/drop, which this implementation avoids.
And it seemed pretty likely someone had gotten used to get/drop followed by
sync updating the branch. It seems much less likely someone is switching
branches, doing get/drop, and then switching back and expecting sync to update
the branch.
Re-running git-annex adjust still does a full re-adjusting of the branch,
for anyone who needs that.
Sponsored-by: Leon Schuermann on Patreon
2023-06-08 18:35:26 +00:00
|
|
|
adjustedBranchRefreshFull' adj origbranch
|
2020-11-16 18:09:55 +00:00
|
|
|
)
|
|
|
|
_ -> return ()
|
|
|
|
|
|
|
|
checkcounter n
|
|
|
|
-- Special case, 1 (or true) refreshes only at shutdown.
|
|
|
|
| n == 1 = pure False
|
|
|
|
| otherwise = Annex.withState $ \s ->
|
|
|
|
let !c = Annex.adjustedbranchrefreshcounter s + 1
|
|
|
|
!enough = c >= pred n
|
|
|
|
!c' = if enough then 0 else c
|
|
|
|
!s' = s { Annex.adjustedbranchrefreshcounter = c' }
|
|
|
|
in pure (s', enough)
|
2020-11-16 19:13:48 +00:00
|
|
|
|
|
|
|
{- Slow, but more dependable version of adjustedBranchRefresh that
|
|
|
|
- does not rely on all AssociatedFiles being known. -}
|
|
|
|
adjustedBranchRefreshFull :: Adjustment -> OrigBranch -> Annex ()
|
sync: use log to track adjusted branch needs updating
Speeds up sync in an adjusted branch by avoiding re-adjusting the branch
unncessarily, particularly when it is adjusted with --hide-missing or
--unlock-present.
When there are a lot of files, that was the majority of the time of a
--no-content sync.
Uses a log file, which is updated when content presence changes. This
adds a little bit of overhead to every file get/drop when on such an
adjusted branch. The overhead is minimal for get of any size of file,
but might be noticable for drop in some cases. It seems like a reasonable
trade-off. It would be possible to update the log file only at the end, but
then it would not happen if the command is interrupted.
When not in an adjusted branch, there should be no additional overhead.
(getCurrentBranch is an MVar read, and it avoids the MVar read of
getGitConfig.)
Note that this does not deal with situations such as:
git checkout master, git-annex get, git checkout adjusted branch,
git-annex sync. The sync won't know that the adjusted branch needs to be
updated. Dealing with that would add overhead to operation in non-adjusted
branches, which I don't like. Also, there are other situations like having
two adjusted branches that both need to be updated like this, and switching
between them and sync not updating.
This does mean a behavior change to sync, since it did previously deal
with those situations. But, the documentation did not say that it did.
The man pages only talk about sync updating the adjusted branch after
it transfers content.
I did consider making sync keep track of content it transferred (and
dropped) and only update the adjusted branch then, not to catch up to other
changes made previously. That would perform better. But it seemed rather
hard to implement, and also it would have problems with races with a
concurrent get/drop, which this implementation avoids.
And it seemed pretty likely someone had gotten used to get/drop followed by
sync updating the branch. It seems much less likely someone is switching
branches, doing get/drop, and then switching back and expecting sync to update
the branch.
Re-running git-annex adjust still does a full re-adjusting of the branch,
for anyone who needs that.
Sponsored-by: Leon Schuermann on Patreon
2023-06-08 18:35:26 +00:00
|
|
|
adjustedBranchRefreshFull adj origbranch =
|
|
|
|
whenM isAdjustedBranchUpdateNeeded $ do
|
|
|
|
adjustedBranchRefreshFull' adj origbranch
|
|
|
|
|
|
|
|
adjustedBranchRefreshFull' :: Adjustment -> OrigBranch -> Annex ()
|
|
|
|
adjustedBranchRefreshFull' adj origbranch = do
|
2023-03-23 20:23:56 +00:00
|
|
|
-- Restage pointer files so modifications to them due to get/drop
|
|
|
|
-- do not prevent checking out the updated adjusted branch.
|
|
|
|
restagePointerFiles =<< Annex.gitRepo
|
sync: use log to track adjusted branch needs updating
Speeds up sync in an adjusted branch by avoiding re-adjusting the branch
unncessarily, particularly when it is adjusted with --hide-missing or
--unlock-present.
When there are a lot of files, that was the majority of the time of a
--no-content sync.
Uses a log file, which is updated when content presence changes. This
adds a little bit of overhead to every file get/drop when on such an
adjusted branch. The overhead is minimal for get of any size of file,
but might be noticable for drop in some cases. It seems like a reasonable
trade-off. It would be possible to update the log file only at the end, but
then it would not happen if the command is interrupted.
When not in an adjusted branch, there should be no additional overhead.
(getCurrentBranch is an MVar read, and it avoids the MVar read of
getGitConfig.)
Note that this does not deal with situations such as:
git checkout master, git-annex get, git checkout adjusted branch,
git-annex sync. The sync won't know that the adjusted branch needs to be
updated. Dealing with that would add overhead to operation in non-adjusted
branches, which I don't like. Also, there are other situations like having
two adjusted branches that both need to be updated like this, and switching
between them and sync not updating.
This does mean a behavior change to sync, since it did previously deal
with those situations. But, the documentation did not say that it did.
The man pages only talk about sync updating the adjusted branch after
it transfers content.
I did consider making sync keep track of content it transferred (and
dropped) and only update the adjusted branch then, not to catch up to other
changes made previously. That would perform better. But it seemed rather
hard to implement, and also it would have problems with races with a
concurrent get/drop, which this implementation avoids.
And it seemed pretty likely someone had gotten used to get/drop followed by
sync updating the branch. It seems much less likely someone is switching
branches, doing get/drop, and then switching back and expecting sync to update
the branch.
Re-running git-annex adjust still does a full re-adjusting of the branch,
for anyone who needs that.
Sponsored-by: Leon Schuermann on Patreon
2023-06-08 18:35:26 +00:00
|
|
|
starttime <- liftIO getPOSIXTime
|
2020-11-16 19:13:48 +00:00
|
|
|
let adjbranch = originalToAdjusted origbranch adj
|
sync: use log to track adjusted branch needs updating
Speeds up sync in an adjusted branch by avoiding re-adjusting the branch
unncessarily, particularly when it is adjusted with --hide-missing or
--unlock-present.
When there are a lot of files, that was the majority of the time of a
--no-content sync.
Uses a log file, which is updated when content presence changes. This
adds a little bit of overhead to every file get/drop when on such an
adjusted branch. The overhead is minimal for get of any size of file,
but might be noticable for drop in some cases. It seems like a reasonable
trade-off. It would be possible to update the log file only at the end, but
then it would not happen if the command is interrupted.
When not in an adjusted branch, there should be no additional overhead.
(getCurrentBranch is an MVar read, and it avoids the MVar read of
getGitConfig.)
Note that this does not deal with situations such as:
git checkout master, git-annex get, git checkout adjusted branch,
git-annex sync. The sync won't know that the adjusted branch needs to be
updated. Dealing with that would add overhead to operation in non-adjusted
branches, which I don't like. Also, there are other situations like having
two adjusted branches that both need to be updated like this, and switching
between them and sync not updating.
This does mean a behavior change to sync, since it did previously deal
with those situations. But, the documentation did not say that it did.
The man pages only talk about sync updating the adjusted branch after
it transfers content.
I did consider making sync keep track of content it transferred (and
dropped) and only update the adjusted branch then, not to catch up to other
changes made previously. That would perform better. But it seemed rather
hard to implement, and also it would have problems with races with a
concurrent get/drop, which this implementation avoids.
And it seemed pretty likely someone had gotten used to get/drop followed by
sync updating the branch. It seems much less likely someone is switching
branches, doing get/drop, and then switching back and expecting sync to update
the branch.
Re-running git-annex adjust still does a full re-adjusting of the branch,
for anyone who needs that.
Sponsored-by: Leon Schuermann on Patreon
2023-06-08 18:35:26 +00:00
|
|
|
ifM (updateAdjustedBranch adj adjbranch origbranch)
|
|
|
|
( recordAdjustedBranchUpdateFinished starttime
|
|
|
|
, warning "Updating adjusted branch failed."
|
|
|
|
)
|
2020-11-16 18:09:55 +00:00
|
|
|
|
2016-03-29 17:52:13 +00:00
|
|
|
adjustToCrippledFileSystem :: Annex ()
|
|
|
|
adjustToCrippledFileSystem = do
|
|
|
|
warning "Entering an adjusted branch where files are unlocked as this filesystem does not support locked files."
|
2018-12-03 16:57:23 +00:00
|
|
|
checkVersionSupported
|
2020-11-24 16:31:17 +00:00
|
|
|
whenM (isNothing <$> inRepo Git.Branch.current) $
|
|
|
|
commitForAdjustedBranch []
|
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.
2019-10-21 15:04:24 +00:00
|
|
|
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))
|
2020-11-16 18:31:02 +00:00
|
|
|
( unlessM (checkoutAdjustedBranch adjbranch False) $
|
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.
2019-10-21 15:04:24 +00:00
|
|
|
failedenter
|
|
|
|
, unlessM (enterAdjustedBranch adj) $
|
|
|
|
failedenter
|
|
|
|
)
|
|
|
|
Nothing -> failedenter
|
|
|
|
where
|
|
|
|
adj = LinkAdjustment UnlockAdjustment
|
|
|
|
failedenter = warning "Failed to enter adjusted branch!"
|
2016-03-29 17:52:13 +00:00
|
|
|
|
2020-11-24 16:31:17 +00:00
|
|
|
{- Commit before entering adjusted branch. Only needs to be done
|
|
|
|
- when the current branch does not have any commits yet.
|
|
|
|
-
|
|
|
|
- If something is already staged, it will be committed, but otherwise
|
|
|
|
- an empty commit will be made.
|
|
|
|
-}
|
|
|
|
commitForAdjustedBranch :: [CommandParam] -> Annex ()
|
|
|
|
commitForAdjustedBranch ps = do
|
|
|
|
cmode <- annexCommitMode <$> Annex.getGitConfig
|
2021-07-19 15:28:31 +00:00
|
|
|
let cquiet = Git.Branch.CommitQuiet True
|
|
|
|
void $ inRepo $ Git.Branch.commitCommand cmode cquiet $
|
|
|
|
[ Param "--allow-empty"
|
2020-11-24 16:31:17 +00:00
|
|
|
, Param "-m"
|
|
|
|
, Param "commit before entering adjusted branch"
|
|
|
|
] ++ ps
|
|
|
|
|
2016-04-09 19:10:26 +00:00
|
|
|
setBasisBranch :: BasisBranch -> Ref -> Annex ()
|
|
|
|
setBasisBranch (BasisBranch basis) new =
|
2016-04-09 18:12:25 +00:00
|
|
|
inRepo $ Git.Branch.update' basis new
|
|
|
|
|
2016-04-09 19:10:26 +00:00
|
|
|
setAdjustedBranch :: String -> AdjBranch -> Ref -> Annex ()
|
|
|
|
setAdjustedBranch msg (AdjBranch b) r = inRepo $ Git.Branch.update msg b r
|
|
|
|
|
2016-03-11 23:41:11 +00:00
|
|
|
adjustBranch :: Adjustment -> OrigBranch -> Annex AdjBranch
|
|
|
|
adjustBranch adj origbranch = do
|
2016-04-09 18:12:25 +00:00
|
|
|
-- Start basis off with the current value of the origbranch.
|
2016-04-09 19:10:26 +00:00
|
|
|
setBasisBranch basis origbranch
|
2016-04-09 18:12:25 +00:00
|
|
|
sha <- adjustCommit adj basis
|
2016-04-09 19:10:26 +00:00
|
|
|
setAdjustedBranch "entering adjusted branch" adjbranch sha
|
2016-02-25 20:11:13 +00:00
|
|
|
return adjbranch
|
|
|
|
where
|
2016-02-29 19:04:03 +00:00
|
|
|
adjbranch = originalToAdjusted origbranch adj
|
2016-04-09 18:12:25 +00:00
|
|
|
basis = basisBranch adjbranch
|
2016-02-25 20:11:13 +00:00
|
|
|
|
2016-04-09 18:12:25 +00:00
|
|
|
adjustCommit :: Adjustment -> BasisBranch -> Annex Sha
|
|
|
|
adjustCommit adj basis = do
|
|
|
|
treesha <- adjustTree adj basis
|
|
|
|
commitAdjustedTree treesha basis
|
2016-03-03 20:19:09 +00:00
|
|
|
|
2016-04-09 18:12:25 +00:00
|
|
|
adjustTree :: Adjustment -> BasisBranch -> Annex Sha
|
|
|
|
adjustTree adj (BasisBranch basis) = do
|
2016-03-29 15:15:21 +00:00
|
|
|
let toadj = adjustTreeItem adj
|
2019-05-20 20:37:04 +00:00
|
|
|
treesha <- Git.Tree.adjustTree
|
|
|
|
toadj
|
|
|
|
[]
|
|
|
|
(\_old new -> new)
|
|
|
|
[]
|
|
|
|
basis =<< Annex.gitRepo
|
2016-03-03 20:19:09 +00:00
|
|
|
return treesha
|
2016-02-29 21:16:56 +00:00
|
|
|
|
2016-03-11 20:00:14 +00:00
|
|
|
type CommitsPrevented = Git.LockFile.LockHandle
|
|
|
|
|
2016-03-03 16:55:00 +00:00
|
|
|
{- Locks git's index file, preventing git from making a commit, merge,
|
|
|
|
- or otherwise changing the HEAD ref while the action is run.
|
|
|
|
-
|
|
|
|
- Throws an IO exception if the index file is already locked.
|
|
|
|
-}
|
2016-03-11 20:00:14 +00:00
|
|
|
preventCommits :: (CommitsPrevented -> Annex a) -> Annex a
|
|
|
|
preventCommits = bracket setup cleanup
|
2016-03-03 16:55:00 +00:00
|
|
|
where
|
|
|
|
setup = do
|
2018-08-17 20:03:40 +00:00
|
|
|
lck <- fromRepo $ indexFileLock . indexFile
|
2020-11-06 18:10:58 +00:00
|
|
|
liftIO $ Git.LockFile.openLock (fromRawFilePath lck)
|
2016-03-11 20:00:14 +00:00
|
|
|
cleanup = liftIO . Git.LockFile.closeLock
|
2016-03-03 16:55:00 +00:00
|
|
|
|
2016-02-25 20:11:13 +00:00
|
|
|
{- Commits a given adjusted tree, with the provided parent ref.
|
|
|
|
-
|
|
|
|
- This should always yield the same value, even if performed in different
|
|
|
|
- clones of a repo, at different times. The commit message and other
|
|
|
|
- metadata is based on the parent.
|
|
|
|
-}
|
2016-04-09 18:12:25 +00:00
|
|
|
commitAdjustedTree :: Sha -> BasisBranch -> Annex Sha
|
|
|
|
commitAdjustedTree treesha parent@(BasisBranch b) =
|
|
|
|
commitAdjustedTree' treesha parent [b]
|
2016-03-31 22:54:35 +00:00
|
|
|
|
2016-04-09 18:12:25 +00:00
|
|
|
commitAdjustedTree' :: Sha -> BasisBranch -> [Ref] -> Annex Sha
|
|
|
|
commitAdjustedTree' treesha (BasisBranch basis) parents =
|
|
|
|
go =<< catCommit basis
|
2016-02-25 20:11:13 +00:00
|
|
|
where
|
2019-11-11 20:15:05 +00:00
|
|
|
go Nothing = do
|
2019-11-11 22:20:35 +00:00
|
|
|
cmode <- annexCommitMode <$> Annex.getGitConfig
|
2019-11-11 20:15:05 +00:00
|
|
|
inRepo $ mkcommit cmode
|
|
|
|
go (Just basiscommit) = do
|
2019-11-11 22:20:35 +00:00
|
|
|
cmode <- annexCommitMode <$> Annex.getGitConfig
|
2019-11-11 20:15:05 +00:00
|
|
|
inRepo $ commitWithMetaData
|
|
|
|
(commitAuthorMetaData basiscommit)
|
|
|
|
(commitCommitterMetaData basiscommit)
|
|
|
|
(mkcommit cmode)
|
|
|
|
mkcommit cmode = Git.Branch.commitTree cmode
|
2016-03-31 22:54:35 +00:00
|
|
|
adjustedBranchCommitMessage parents treesha
|
2016-03-03 20:19:09 +00:00
|
|
|
|
2016-06-09 18:11:00 +00:00
|
|
|
{- This message should never be changed. -}
|
2016-03-03 20:19:09 +00:00
|
|
|
adjustedBranchCommitMessage :: String
|
|
|
|
adjustedBranchCommitMessage = "git-annex adjusted branch"
|
2016-02-29 19:04:03 +00:00
|
|
|
|
2016-06-09 18:11:00 +00:00
|
|
|
findAdjustingCommit :: AdjBranch -> Annex (Maybe Commit)
|
|
|
|
findAdjustingCommit (AdjBranch b) = go =<< catCommit b
|
|
|
|
where
|
|
|
|
go Nothing = return Nothing
|
|
|
|
go (Just c)
|
|
|
|
| commitMessage c == adjustedBranchCommitMessage = return (Just c)
|
|
|
|
| otherwise = case commitParent c of
|
|
|
|
[p] -> go =<< catCommit p
|
|
|
|
_ -> return Nothing
|
|
|
|
|
2016-02-29 21:16:56 +00:00
|
|
|
{- Check for any commits present on the adjusted branch that have not yet
|
2023-03-14 02:39:16 +00:00
|
|
|
- been propigated to the basis branch, and propagate them to the basis
|
2016-04-09 18:12:25 +00:00
|
|
|
- branch and from there on to the orig branch.
|
2016-03-03 20:19:09 +00:00
|
|
|
-
|
2023-03-13 22:55:18 +00:00
|
|
|
- After propigating the commits back to the basis branch,
|
2016-04-09 18:12:25 +00:00
|
|
|
- rebase the adjusted branch on top of the updated basis branch.
|
2016-03-03 20:19:09 +00:00
|
|
|
-}
|
2016-04-09 19:10:26 +00:00
|
|
|
propigateAdjustedCommits :: OrigBranch -> Adjustment -> Annex ()
|
|
|
|
propigateAdjustedCommits origbranch adj =
|
2016-04-06 19:33:29 +00:00
|
|
|
preventCommits $ \commitsprevented ->
|
2016-04-09 19:10:26 +00:00
|
|
|
join $ snd <$> propigateAdjustedCommits' origbranch adj commitsprevented
|
2016-03-31 22:54:35 +00:00
|
|
|
|
2016-04-09 18:12:25 +00:00
|
|
|
{- Returns sha of updated basis branch, and action which will rebase
|
|
|
|
- the adjusted branch on top of the updated basis branch. -}
|
2016-03-31 22:54:35 +00:00
|
|
|
propigateAdjustedCommits'
|
|
|
|
:: OrigBranch
|
2016-04-09 19:10:26 +00:00
|
|
|
-> Adjustment
|
2016-03-31 22:54:35 +00:00
|
|
|
-> CommitsPrevented
|
2016-04-06 19:33:29 +00:00
|
|
|
-> Annex (Maybe Sha, Annex ())
|
2017-11-15 20:55:38 +00:00
|
|
|
propigateAdjustedCommits' origbranch adj _commitsprevented =
|
|
|
|
inRepo (Git.Ref.sha basis) >>= \case
|
|
|
|
Just origsha -> catCommit currbranch >>= \case
|
|
|
|
Just currcommit ->
|
|
|
|
newcommits >>= go origsha False >>= \case
|
|
|
|
Left e -> do
|
filter out control characters in warning messages
Converted warning and similar to use StringContainingQuotedPath. Most
warnings are static strings, some do refer to filepaths that need to be
quoted, and others don't need quoting.
Note that, since quote filters out control characters of even
UnquotedString, this makes all warnings safe, even when an attacker
sneaks in a control character in some other way.
When json is being output, no quoting is done, since json gets its own
quoting.
This does, as a side effect, make warning messages in json output not
be indented. The indentation is only needed to offset warning messages
underneath the display of the file they apply to, so that's ok.
Sponsored-by: Brett Eisenberg on Patreon
2023-04-10 18:47:32 +00:00
|
|
|
warning (UnquotedString e)
|
2017-11-15 20:55:38 +00:00
|
|
|
return (Nothing, return ())
|
|
|
|
Right newparent -> return
|
|
|
|
( Just newparent
|
|
|
|
, rebase currcommit newparent
|
|
|
|
)
|
|
|
|
Nothing -> return (Nothing, return ())
|
2023-02-10 18:33:21 +00:00
|
|
|
Nothing -> do
|
filter out control characters in warning messages
Converted warning and similar to use StringContainingQuotedPath. Most
warnings are static strings, some do refer to filepaths that need to be
quoted, and others don't need quoting.
Note that, since quote filters out control characters of even
UnquotedString, this makes all warnings safe, even when an attacker
sneaks in a control character in some other way.
When json is being output, no quoting is done, since json gets its own
quoting.
This does, as a side effect, make warning messages in json output not
be indented. The indentation is only needed to offset warning messages
underneath the display of the file they apply to, so that's ok.
Sponsored-by: Brett Eisenberg on Patreon
2023-04-10 18:47:32 +00:00
|
|
|
warning $ UnquotedString $
|
|
|
|
"Cannot find basis ref " ++ fromRef basis ++ "; not propagating adjusted commits to original branch " ++ fromRef origbranch
|
2023-02-10 18:33:21 +00:00
|
|
|
return (Nothing, return ())
|
2016-03-03 20:19:09 +00:00
|
|
|
where
|
2016-04-09 18:12:25 +00:00
|
|
|
(BasisBranch basis) = basisBranch adjbranch
|
2016-04-09 19:10:26 +00:00
|
|
|
adjbranch@(AdjBranch currbranch) = originalToAdjusted origbranch adj
|
2016-04-09 18:12:25 +00:00
|
|
|
newcommits = inRepo $ Git.Branch.changedCommits basis currbranch
|
2016-03-03 20:19:09 +00:00
|
|
|
-- Get commits oldest first, so they can be processed
|
|
|
|
-- in order made.
|
|
|
|
[Param "--reverse"]
|
2016-03-29 15:15:21 +00:00
|
|
|
go parent _ [] = do
|
2016-04-09 19:10:26 +00:00
|
|
|
setBasisBranch (BasisBranch basis) parent
|
2016-04-09 18:12:25 +00:00
|
|
|
inRepo $ Git.Branch.update' origbranch parent
|
2016-03-11 20:00:14 +00:00
|
|
|
return (Right parent)
|
2017-11-15 20:55:38 +00:00
|
|
|
go parent pastadjcommit (sha:l) = catCommit sha >>= \case
|
|
|
|
Just c
|
|
|
|
| commitMessage c == adjustedBranchCommitMessage ->
|
|
|
|
go parent True l
|
|
|
|
| pastadjcommit ->
|
|
|
|
reverseAdjustedCommit parent adj (sha, c) origbranch
|
|
|
|
>>= \case
|
2016-03-11 20:00:14 +00:00
|
|
|
Left e -> return (Left e)
|
2016-03-29 15:15:21 +00:00
|
|
|
Right commit -> go commit pastadjcommit l
|
2017-11-15 20:55:38 +00:00
|
|
|
_ -> go parent pastadjcommit l
|
2016-03-03 21:00:48 +00:00
|
|
|
rebase currcommit newparent = do
|
2016-04-09 18:12:25 +00:00
|
|
|
-- Reuse the current adjusted tree, and reparent it
|
|
|
|
-- on top of the newparent.
|
|
|
|
commitAdjustedTree (commitTree currcommit) (BasisBranch newparent)
|
2016-03-31 22:54:35 +00:00
|
|
|
>>= inRepo . Git.Branch.update rebaseOnTopMsg currbranch
|
2016-03-03 20:19:09 +00:00
|
|
|
|
2016-03-31 22:54:35 +00:00
|
|
|
rebaseOnTopMsg :: String
|
|
|
|
rebaseOnTopMsg = "rebasing adjusted branch on top of updated original branch"
|
|
|
|
|
|
|
|
{- Reverses an adjusted commit, and commit with provided commitparent,
|
2016-03-11 20:00:14 +00:00
|
|
|
- yielding a commit sha.
|
|
|
|
-
|
2016-03-31 22:54:35 +00:00
|
|
|
- Adjusts the tree of the commitparent, changing only the files that the
|
2016-03-11 20:00:14 +00:00
|
|
|
- commit changed, and reverse adjusting those changes.
|
2016-03-03 20:19:09 +00:00
|
|
|
-
|
2016-03-31 22:54:35 +00:00
|
|
|
- The commit message, and the author and committer metadata are
|
|
|
|
- copied over from the basiscommit. However, any gpg signature
|
|
|
|
- will be lost, and any other headers are not copied either. -}
|
2016-03-29 15:15:21 +00:00
|
|
|
reverseAdjustedCommit :: Sha -> Adjustment -> (Sha, Commit) -> OrigBranch -> Annex (Either String Sha)
|
2016-03-31 22:54:35 +00:00
|
|
|
reverseAdjustedCommit commitparent adj (csha, basiscommit) origbranch
|
|
|
|
| length (commitParent basiscommit) > 1 = return $
|
2023-03-14 02:39:16 +00:00
|
|
|
Left $ "unable to propagate merge commit " ++ show csha ++ " back to " ++ show origbranch
|
2016-03-11 20:00:14 +00:00
|
|
|
| otherwise = do
|
2019-11-11 22:20:35 +00:00
|
|
|
cmode <- annexCommitMode <$> Annex.getGitConfig
|
2016-03-31 22:54:35 +00:00
|
|
|
treesha <- reverseAdjustedTree commitparent adj csha
|
2016-03-11 20:00:14 +00:00
|
|
|
revadjcommit <- inRepo $ commitWithMetaData
|
2016-03-31 22:54:35 +00:00
|
|
|
(commitAuthorMetaData basiscommit)
|
|
|
|
(commitCommitterMetaData basiscommit) $
|
2019-11-11 20:15:05 +00:00
|
|
|
Git.Branch.commitTree cmode
|
|
|
|
(commitMessage basiscommit)
|
|
|
|
[commitparent] treesha
|
2016-03-11 20:00:14 +00:00
|
|
|
return (Right revadjcommit)
|
2016-03-31 22:54:35 +00:00
|
|
|
|
|
|
|
{- Adjusts the tree of the basis, changing only the files that the
|
|
|
|
- commit changed, and reverse adjusting those changes.
|
|
|
|
-
|
|
|
|
- commitDiff does not support merge commits, so the csha must not be a
|
|
|
|
- merge commit. -}
|
|
|
|
reverseAdjustedTree :: Sha -> Adjustment -> Sha -> Annex Sha
|
|
|
|
reverseAdjustedTree basis adj csha = do
|
|
|
|
(diff, cleanup) <- inRepo (Git.DiffTree.commitDiff csha)
|
2020-01-07 15:35:17 +00:00
|
|
|
let (adds, others) = partition (\dti -> Git.DiffTree.srcsha dti `elem` nullShas) diff
|
|
|
|
let (removes, changes) = partition (\dti -> Git.DiffTree.dstsha dti `elem` nullShas) others
|
2016-03-31 22:54:35 +00:00
|
|
|
adds' <- catMaybes <$>
|
|
|
|
mapM (adjustTreeItem reverseadj) (map diffTreeToTreeItem adds)
|
|
|
|
treesha <- Git.Tree.adjustTree
|
|
|
|
(propchanges changes)
|
|
|
|
adds'
|
2019-05-20 20:37:04 +00:00
|
|
|
(\_old new -> new)
|
2016-03-31 22:54:35 +00:00
|
|
|
(map Git.DiffTree.file removes)
|
|
|
|
basis
|
|
|
|
=<< Annex.gitRepo
|
|
|
|
void $ liftIO cleanup
|
|
|
|
return treesha
|
2016-03-11 20:00:14 +00:00
|
|
|
where
|
2016-03-11 23:41:11 +00:00
|
|
|
reverseadj = reverseAdjustment adj
|
2016-03-11 20:00:14 +00:00
|
|
|
propchanges changes ti@(TreeItem f _ _) =
|
2016-05-04 16:57:07 +00:00
|
|
|
case M.lookup (norm f) m of
|
2016-03-11 20:00:14 +00:00
|
|
|
Nothing -> return (Just ti) -- not changed
|
2016-03-29 15:15:21 +00:00
|
|
|
Just change -> adjustTreeItem reverseadj change
|
2016-03-11 20:00:14 +00:00
|
|
|
where
|
2016-05-04 16:57:07 +00:00
|
|
|
m = M.fromList $ map (\i@(TreeItem f' _ _) -> (norm f', i)) $
|
2016-03-11 20:00:14 +00:00
|
|
|
map diffTreeToTreeItem changes
|
2019-12-09 17:49:05 +00:00
|
|
|
norm = normalise . fromRawFilePath . getTopFilePath
|
2016-03-11 20:00:14 +00:00
|
|
|
|
|
|
|
diffTreeToTreeItem :: Git.DiffTree.DiffTreeItem -> TreeItem
|
|
|
|
diffTreeToTreeItem dti = TreeItem
|
|
|
|
(Git.DiffTree.file dti)
|
|
|
|
(Git.DiffTree.dstmode dti)
|
|
|
|
(Git.DiffTree.dstsha dti)
|
2016-04-04 17:51:42 +00:00
|
|
|
|
2019-08-30 17:54:57 +00:00
|
|
|
data AdjustedClone = InAdjustedClone | NotInAdjustedClone
|
2016-06-02 19:58:22 +00:00
|
|
|
|
2016-04-04 17:51:42 +00:00
|
|
|
{- Cloning a repository that has an adjusted branch checked out will
|
|
|
|
- result in the clone having the same adjusted branch checked out -- but
|
2016-06-09 18:11:00 +00:00
|
|
|
- the origbranch won't exist in the clone, nor will the basis. So
|
|
|
|
- to properly set up the adjusted branch, the origbranch and basis need
|
|
|
|
- to be set.
|
|
|
|
-
|
|
|
|
- We can't trust that the origin's origbranch matches up with the currently
|
|
|
|
- checked out adjusted branch; the origin could have the two branches
|
|
|
|
- out of sync (eg, due to another branch having been pushed to the origin's
|
|
|
|
- origbranch), or due to a commit on its adjusted branch not having been
|
|
|
|
- propigated back to origbranch.
|
|
|
|
-
|
|
|
|
- So, find the adjusting commit on the currently checked out adjusted
|
|
|
|
- branch, and use the parent of that commit as the basis, and set the
|
|
|
|
- origbranch to it.
|
2021-04-14 22:32:15 +00:00
|
|
|
-}
|
2016-06-02 19:58:22 +00:00
|
|
|
checkAdjustedClone :: Annex AdjustedClone
|
2016-06-02 21:02:38 +00:00
|
|
|
checkAdjustedClone = ifM isBareRepo
|
|
|
|
( return NotInAdjustedClone
|
|
|
|
, go =<< inRepo Git.Branch.current
|
|
|
|
)
|
2016-04-04 17:51:42 +00:00
|
|
|
where
|
2016-06-02 19:58:22 +00:00
|
|
|
go Nothing = return NotInAdjustedClone
|
2016-04-04 17:51:42 +00:00
|
|
|
go (Just currbranch) = case adjustedToOriginal currbranch of
|
2016-06-02 19:58:22 +00:00
|
|
|
Nothing -> return NotInAdjustedClone
|
2016-04-09 18:12:25 +00:00
|
|
|
Just (adj, origbranch) -> do
|
|
|
|
let basis@(BasisBranch bb) = basisBranch (originalToAdjusted origbranch adj)
|
2016-06-09 18:11:00 +00:00
|
|
|
unlessM (inRepo $ Git.Ref.exists bb) $ do
|
|
|
|
aps <- fmap commitParent <$> findAdjustingCommit (AdjBranch currbranch)
|
|
|
|
case aps of
|
2021-04-14 22:53:27 +00:00
|
|
|
Just [p] -> do
|
|
|
|
unlessM (inRepo $ Git.Ref.exists origbranch) $
|
|
|
|
inRepo $ Git.Branch.update' origbranch p
|
|
|
|
setBasisBranch basis p
|
2016-11-16 01:29:54 +00:00
|
|
|
_ -> giveup $ "Unable to clean up from clone of adjusted branch; perhaps you should check out " ++ Git.Ref.describe origbranch
|
2019-08-30 17:54:57 +00:00
|
|
|
return InAdjustedClone
|
2016-04-22 16:29:32 +00:00
|
|
|
|
|
|
|
checkVersionSupported :: Annex ()
|
2019-08-30 17:54:57 +00:00
|
|
|
checkVersionSupported =
|
2016-04-22 16:29:32 +00:00
|
|
|
unlessM (liftIO isGitVersionSupported) $
|
2016-11-16 01:29:54 +00:00
|
|
|
giveup "Your version of git is too old; upgrade it to 2.2.0 or newer to use adjusted branches."
|
2018-10-22 20:51:09 +00:00
|
|
|
|
|
|
|
-- git 2.2.0 needed for GIT_COMMON_DIR which is needed
|
|
|
|
-- by updateAdjustedBranch to use withWorkTreeRelated.
|
|
|
|
isGitVersionSupported :: IO Bool
|
|
|
|
isGitVersionSupported = not <$> Git.Version.older "2.2.0"
|