From 38153ad340be885ea8bb7dd0b7df855123374a76 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 12 Jun 2023 13:25:04 -0400 Subject: [PATCH] assistant: Add dotfiles to git by default, unless annex.dotfiles is configured Tthe same as git-annex add does. Sponsored-by: Luke Shumaker on Patreon --- Assistant/Threads/Committer.hs | 23 ++++++++++++------- CHANGELOG | 2 ++ ..._assistant_adds_dotfiles_to_the_annex.mdwn | 2 ++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Assistant/Threads/Committer.hs b/Assistant/Threads/Committer.hs index 8929a722af..62341564f6 100644 --- a/Assistant/Threads/Committer.hs +++ b/Assistant/Threads/Committer.hs @@ -38,6 +38,7 @@ import qualified Annex import Utility.InodeCache import qualified Database.Keys import qualified Command.Sync +import Config.GitConfig import Utility.Tuple import Utility.Metered import qualified Utility.RawFilePath as R @@ -56,6 +57,7 @@ commitThread = namedThread "Committer" $ do delayadd <- liftAnnex $ fmap Seconds . annexDelayAdd <$> Annex.getGitConfig largefilematcher <- liftAnnex largeFilesMatcher + annexdotfiles <- liftAnnex $ getGitConfigVal annexDotFiles msg <- liftAnnex Command.Sync.commitMsg lockdowndir <- liftAnnex $ fromRepo gitAnnexTmpWatcherDir liftAnnex $ do @@ -65,7 +67,7 @@ commitThread = namedThread "Committer" $ do (fromRawFilePath lockdowndir) void $ createAnnexDirectory lockdowndir waitChangeTime $ \(changes, time) -> do - readychanges <- handleAdds (fromRawFilePath lockdowndir) havelsof largefilematcher delayadd $ + readychanges <- handleAdds (fromRawFilePath lockdowndir) havelsof largefilematcher annexdotfiles delayadd $ simplifyChanges changes if shouldCommit False time (length readychanges) readychanges then do @@ -261,8 +263,8 @@ commitStaged msg = do - Any pending adds that are not ready yet are put back into the ChangeChan, - where they will be retried later. -} -handleAdds :: FilePath -> Bool -> GetFileMatcher -> Maybe Seconds -> [Change] -> Assistant [Change] -handleAdds lockdowndir havelsof largefilematcher delayadd cs = returnWhen (null incomplete) $ do +handleAdds :: FilePath -> Bool -> GetFileMatcher -> Bool -> Maybe Seconds -> [Change] -> Assistant [Change] +handleAdds lockdowndir havelsof largefilematcher annexdotfiles delayadd cs = returnWhen (null incomplete) $ do let (pending, inprocess) = partition isPendingAddChange incomplete let lockdownconfig = LockDownConfig { lockingFile = False @@ -289,11 +291,16 @@ handleAdds lockdowndir havelsof largefilematcher delayadd cs = returnWhen (null | c = return otherchanges | otherwise = a - checksmall change = - ifM (liftAnnex $ checkFileMatcher largefilematcher (toRawFilePath (changeFile change))) - ( return (Left change) - , return (Right change) - ) + checksmall change + | not annexdotfiles && dotfile f = + return (Right change) + | otherwise = + ifM (liftAnnex $ checkFileMatcher largefilematcher f) + ( return (Left change) + , return (Right change) + ) + where + f = toRawFilePath (changeFile change) addsmall [] = noop addsmall toadd = liftAnnex $ Annex.Queue.addCommand [] "add" diff --git a/CHANGELOG b/CHANGELOG index 25f892ff17..14c306bb27 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -86,6 +86,8 @@ git-annex (10.20230408) UNRELEASED; urgency=medium * Speed up sync in an adjusted branch by avoiding re-adjusting the branch unncessarily, particularly when it is adjusted with --hide-missing or --unlock-present. + * assistant: Add dotfiles to git by default, unless annex.dotfiles + is configured, the same as git-annex add does. -- Joey Hess Sat, 08 Apr 2023 13:57:18 -0400 diff --git a/doc/bugs/git_annex_assistant_adds_dotfiles_to_the_annex.mdwn b/doc/bugs/git_annex_assistant_adds_dotfiles_to_the_annex.mdwn index 0c7b3587cf..31a2d6ec67 100644 --- a/doc/bugs/git_annex_assistant_adds_dotfiles_to_the_annex.mdwn +++ b/doc/bugs/git_annex_assistant_adds_dotfiles_to_the_annex.mdwn @@ -31,3 +31,5 @@ add .somedotfile ok # End of transcript or log. """]] + +> [[fixed|done]] --[[Joey]]