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
This commit is contained in:
Joey Hess 2023-06-12 13:25:04 -04:00
parent 357291c13c
commit 38153ad340
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 19 additions and 8 deletions

View file

@ -38,6 +38,7 @@ import qualified Annex
import Utility.InodeCache import Utility.InodeCache
import qualified Database.Keys import qualified Database.Keys
import qualified Command.Sync import qualified Command.Sync
import Config.GitConfig
import Utility.Tuple import Utility.Tuple
import Utility.Metered import Utility.Metered
import qualified Utility.RawFilePath as R import qualified Utility.RawFilePath as R
@ -56,6 +57,7 @@ commitThread = namedThread "Committer" $ do
delayadd <- liftAnnex $ delayadd <- liftAnnex $
fmap Seconds . annexDelayAdd <$> Annex.getGitConfig fmap Seconds . annexDelayAdd <$> Annex.getGitConfig
largefilematcher <- liftAnnex largeFilesMatcher largefilematcher <- liftAnnex largeFilesMatcher
annexdotfiles <- liftAnnex $ getGitConfigVal annexDotFiles
msg <- liftAnnex Command.Sync.commitMsg msg <- liftAnnex Command.Sync.commitMsg
lockdowndir <- liftAnnex $ fromRepo gitAnnexTmpWatcherDir lockdowndir <- liftAnnex $ fromRepo gitAnnexTmpWatcherDir
liftAnnex $ do liftAnnex $ do
@ -65,7 +67,7 @@ commitThread = namedThread "Committer" $ do
(fromRawFilePath lockdowndir) (fromRawFilePath lockdowndir)
void $ createAnnexDirectory lockdowndir void $ createAnnexDirectory lockdowndir
waitChangeTime $ \(changes, time) -> do waitChangeTime $ \(changes, time) -> do
readychanges <- handleAdds (fromRawFilePath lockdowndir) havelsof largefilematcher delayadd $ readychanges <- handleAdds (fromRawFilePath lockdowndir) havelsof largefilematcher annexdotfiles delayadd $
simplifyChanges changes simplifyChanges changes
if shouldCommit False time (length readychanges) readychanges if shouldCommit False time (length readychanges) readychanges
then do then do
@ -261,8 +263,8 @@ commitStaged msg = do
- Any pending adds that are not ready yet are put back into the ChangeChan, - Any pending adds that are not ready yet are put back into the ChangeChan,
- where they will be retried later. - where they will be retried later.
-} -}
handleAdds :: FilePath -> Bool -> GetFileMatcher -> Maybe Seconds -> [Change] -> Assistant [Change] handleAdds :: FilePath -> Bool -> GetFileMatcher -> Bool -> Maybe Seconds -> [Change] -> Assistant [Change]
handleAdds lockdowndir havelsof largefilematcher delayadd cs = returnWhen (null incomplete) $ do handleAdds lockdowndir havelsof largefilematcher annexdotfiles delayadd cs = returnWhen (null incomplete) $ do
let (pending, inprocess) = partition isPendingAddChange incomplete let (pending, inprocess) = partition isPendingAddChange incomplete
let lockdownconfig = LockDownConfig let lockdownconfig = LockDownConfig
{ lockingFile = False { lockingFile = False
@ -289,11 +291,16 @@ handleAdds lockdowndir havelsof largefilematcher delayadd cs = returnWhen (null
| c = return otherchanges | c = return otherchanges
| otherwise = a | otherwise = a
checksmall change = checksmall change
ifM (liftAnnex $ checkFileMatcher largefilematcher (toRawFilePath (changeFile change))) | not annexdotfiles && dotfile f =
( return (Left change) return (Right change)
, return (Right change) | otherwise =
) ifM (liftAnnex $ checkFileMatcher largefilematcher f)
( return (Left change)
, return (Right change)
)
where
f = toRawFilePath (changeFile change)
addsmall [] = noop addsmall [] = noop
addsmall toadd = liftAnnex $ Annex.Queue.addCommand [] "add" addsmall toadd = liftAnnex $ Annex.Queue.addCommand [] "add"

View file

@ -86,6 +86,8 @@ git-annex (10.20230408) UNRELEASED; urgency=medium
* Speed up sync in an adjusted branch by avoiding re-adjusting the branch * Speed up sync in an adjusted branch by avoiding re-adjusting the branch
unncessarily, particularly when it is adjusted with --hide-missing unncessarily, particularly when it is adjusted with --hide-missing
or --unlock-present. or --unlock-present.
* assistant: Add dotfiles to git by default, unless annex.dotfiles
is configured, the same as git-annex add does.
-- Joey Hess <id@joeyh.name> Sat, 08 Apr 2023 13:57:18 -0400 -- Joey Hess <id@joeyh.name> Sat, 08 Apr 2023 13:57:18 -0400

View file

@ -31,3 +31,5 @@ add .somedotfile ok
# End of transcript or log. # End of transcript or log.
"""]] """]]
> [[fixed|done]] --[[Joey]]