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 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"

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
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 <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.
"""]]
> [[fixed|done]] --[[Joey]]