From: Joey Hess Date: Mon, 25 Jan 2021 17:55:01 +0000 (-0400) Subject: When adding files to an adjusted branch set up by --unlock-present, add them unlocked... X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~98^2~134 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6f78497572e14d604adf0212fc19170e68aa755e;p=git-annex.git 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. --- diff --git a/Annex/Ingest.hs b/Annex/Ingest.hs index a23c193769..66e1d71c69 100644 --- a/Annex/Ingest.hs +++ b/Annex/Ingest.hs @@ -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) diff --git a/CHANGELOG b/CHANGELOG index b5f92b2c3a..a325d90671 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 Thu, 28 Jan 2021 12:34:32 -0400 diff --git a/Command/Add.hs b/Command/Add.hs index 0835f0946e..73e355b421 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -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 diff --git a/Command/Import.hs b/Command/Import.hs index cbd344f0d9..d1957e0582 100644 --- a/Command/Import.hs +++ b/Command/Import.hs @@ -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 diff --git a/doc/bugs/adjustedbranchrefresh_ignored_by_git_annex_add.mdwn b/doc/bugs/adjustedbranchrefresh_ignored_by_git_annex_add.mdwn index 025cf887b6..756fd0291d 100644 --- a/doc/bugs/adjustedbranchrefresh_ignored_by_git_annex_add.mdwn +++ b/doc/bugs/adjustedbranchrefresh_ignored_by_git_annex_add.mdwn @@ -50,3 +50,5 @@ echo "## after sync --content" stat -c "%n: %F" a b c d # ibid ' ``` + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/adjustedbranchrefresh_ignored_by_git_annex_add/comment_2_da0e37920a879bdb9df3fef87d52a10c._comment b/doc/bugs/adjustedbranchrefresh_ignored_by_git_annex_add/comment_2_da0e37920a879bdb9df3fef87d52a10c._comment new file mode 100644 index 0000000000..3437e9c12e --- /dev/null +++ b/doc/bugs/adjustedbranchrefresh_ignored_by_git_annex_add/comment_2_da0e37920a879bdb9df3fef87d52a10c._comment @@ -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. +"""]]