When adding files to an adjusted branch set up by --unlock-present, add them unlocked, not locked
Missed this when implementing it because of the default case catching the new constructor. So, removed that default case to make sure future types of adjusted branches don't make the same mistake. Complicated by git-annex addurl --fast which adds the file whose content is not present, so it needs to stay unlocked when on such a branch. This commit was sponsored by Brock Spratlen on Patreon.
This commit is contained in:
parent
db1e6c0625
commit
6f78497572
6 changed files with 28 additions and 9 deletions
|
@ -329,18 +329,24 @@ gitAddParams (CheckGitIgnore False) = return [Param "-f"]
|
|||
|
||||
{- Whether a file should be added unlocked or not. Default is to not,
|
||||
- unless symlinks are not supported. annex.addunlocked can override that.
|
||||
- Also, when in an adjusted unlocked branch, always add files unlocked.
|
||||
- Also, when in an adjusted branch that unlocked files, always add files
|
||||
- unlocked.
|
||||
-}
|
||||
addUnlocked :: AddUnlockedMatcher -> MatchInfo -> Annex Bool
|
||||
addUnlocked matcher mi =
|
||||
addUnlocked :: AddUnlockedMatcher -> MatchInfo -> Bool -> Annex Bool
|
||||
addUnlocked matcher mi contentpresent =
|
||||
((not . coreSymlinks <$> Annex.getGitConfig) <||>
|
||||
(checkAddUnlockedMatcher matcher mi) <||>
|
||||
(maybe False isadjustedunlocked . snd <$> getCurrentBranch)
|
||||
(maybe False go . snd <$> getCurrentBranch)
|
||||
)
|
||||
where
|
||||
isadjustedunlocked (LinkAdjustment UnlockAdjustment) = True
|
||||
isadjustedunlocked (PresenceAdjustment _ (Just UnlockAdjustment)) = True
|
||||
isadjustedunlocked _ = False
|
||||
go (LinkAdjustment UnlockAdjustment) = True
|
||||
go (LinkAdjustment LockAdjustment) = False
|
||||
go (LinkAdjustment FixAdjustment) = False
|
||||
go (LinkAdjustment UnFixAdjustment) = False
|
||||
go (PresenceAdjustment _ (Just la)) = go (LinkAdjustment la)
|
||||
go (PresenceAdjustment _ Nothing) = False
|
||||
go (LinkPresentAdjustment UnlockPresentAdjustment) = contentpresent
|
||||
go (LinkPresentAdjustment LockPresentAdjustment) = False
|
||||
|
||||
{- Adds a file to the work tree for the key, and stages it in the index.
|
||||
- The content of the key may be provided in a temp file, which will be
|
||||
|
@ -350,7 +356,7 @@ addUnlocked matcher mi =
|
|||
- When the content of the key is not accepted into the annex, returns False.
|
||||
-}
|
||||
addAnnexedFile :: CheckGitIgnore -> AddUnlockedMatcher -> RawFilePath -> Key -> Maybe RawFilePath -> Annex Bool
|
||||
addAnnexedFile ci matcher file key mtmp = ifM (addUnlocked matcher mi)
|
||||
addAnnexedFile ci matcher file key mtmp = ifM (addUnlocked matcher mi (isJust mtmp))
|
||||
( do
|
||||
mode <- maybe
|
||||
(pure Nothing)
|
||||
|
|
|
@ -3,6 +3,8 @@ git-annex (8.20210128) UNRELEASED; urgency=medium
|
|||
* Fix a reversion that made import of a tree from a special remote
|
||||
result in a merge that deleted files that were not preferred content
|
||||
of that special remote.
|
||||
* When adding files to an adjusted branch set up by --unlock-present,
|
||||
add them unlocked, not locked.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Thu, 28 Jan 2021 12:34:32 -0400
|
||||
|
||||
|
|
|
@ -172,6 +172,7 @@ perform :: AddOptions -> RawFilePath -> AddUnlockedMatcher -> CommandPerform
|
|||
perform o file addunlockedmatcher = withOtherTmp $ \tmpdir -> do
|
||||
lockingfile <- not <$> addUnlocked addunlockedmatcher
|
||||
(MatchingFile (FileInfo (Just file) file Nothing))
|
||||
True
|
||||
let cfg = LockDownConfig
|
||||
{ lockingFile = lockingfile
|
||||
, hardlinkFileTmpDir = Just tmpdir
|
||||
|
|
|
@ -243,7 +243,7 @@ startLocal o addunlockedmatcher largematcher mode (srcfile, destfile) =
|
|||
, matchFile = destfile
|
||||
, matchKey = Nothing
|
||||
}
|
||||
lockingfile <- not <$> addUnlocked addunlockedmatcher mi
|
||||
lockingfile <- not <$> addUnlocked addunlockedmatcher mi True
|
||||
-- Minimal lock down with no hard linking so nothing
|
||||
-- has to be done to clean up from it.
|
||||
let cfg = LockDownConfig
|
||||
|
|
|
@ -50,3 +50,5 @@ echo "## after sync --content"
|
|||
stat -c "%n: %F" a b c d # ibid
|
||||
'
|
||||
```
|
||||
|
||||
> [[fixed|done]] --[[Joey]]
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 2"""
|
||||
date="2021-01-25T17:46:03Z"
|
||||
content="""
|
||||
Oh, git-annex add already adds it unlocked in an adjusted unlocked branch,
|
||||
so that just needs to be done for this new type of branch too.
|
||||
"""]]
|
Loading…
Reference in a new issue