add: When adding a dotfile as a non-large file, mention that it's a dotfile

This is to reduce user confusion when their annex.largefiles matches it,
or is not set.

Note that, when annex.dotfiles is set, but a dotfile is not matched by
annex.largefiles, the "non-large file" message will be displayed. That
makes sense because whether the file is a dotfile does not matter with that
configuration.

Also, this slightly optimised the annex.dotfiles path in passing,
by avoiding the slight slowdown caused by the check added in commit
876d5b6c6f in that case.
This commit is contained in:
Joey Hess 2024-11-13 14:09:24 -04:00
parent 876d5b6c6f
commit b94221594b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 24 additions and 19 deletions

View file

@ -5,6 +5,8 @@ git-annex (10.20241032) UNRELEASED; urgency=medium
* vpop: Only update state after successful checkout.
* add: Consistently treat files in a dotdir as dotfiles, even
when ran inside that dotdir.
* add: When adding a dotfile as a non-large file, mention that it's a
dotfile.
-- Joey Hess <id@joeyh.name> Mon, 11 Nov 2024 12:26:00 -0400

View file

@ -95,18 +95,20 @@ seek' o = do
annexdotfiles <- getGitConfigVal annexDotFiles
let gofile includingsmall (si, file) = case largeFilesOverride o of
Nothing -> do
topfile <- getTopFilePath <$> inRepo (toTopFilePath file)
ifM (pure (annexdotfiles || not (dotfile topfile))
<&&> (checkFileMatcher NoLiveUpdate largematcher file
<||> Annex.getRead Annex.force))
( start dr si file addunlockedmatcher
, if includingsmall
isdotfile <- if annexdotfiles
then pure False
else dotfile . getTopFilePath
<$> inRepo (toTopFilePath file)
islarge <- checkFileMatcher NoLiveUpdate largematcher file
<||> Annex.getRead Annex.force
if (not isdotfile && islarge)
then start dr si file addunlockedmatcher
else if includingsmall
then ifM (annexAddSmallFiles <$> Annex.getGitConfig)
( startSmall dr si file
( startSmall isdotfile dr si file
, stop
)
else stop
)
Just True -> start dr si file addunlockedmatcher
Just False -> startSmallOverridden dr si file
case batchOption o of
@ -138,17 +140,18 @@ seek' o = do
dr = dryRunOption o
{- Pass file off to git-add. -}
startSmall :: DryRun -> SeekInput -> RawFilePath -> CommandStart
startSmall dr si file =
startSmall :: Bool -> DryRun -> SeekInput -> RawFilePath -> CommandStart
startSmall isdotfile dr si file =
liftIO (catchMaybeIO $ R.getSymbolicLinkStatus file) >>= \case
Just s ->
starting "add" (ActionItemTreeFile file) si $
addSmall dr file s
addSmall isdotfile dr file s
Nothing -> stop
addSmall :: DryRun -> RawFilePath -> FileStatus -> CommandPerform
addSmall dr file s = do
showNote "non-large file; adding content to git repository"
addSmall :: Bool -> DryRun -> RawFilePath -> FileStatus -> CommandPerform
addSmall isdotfile dr file s = do
showNote $ (if isdotfile then "dotfile" else "non-large file")
<> "; adding content to git repository"
skipWhenDryRun dr $ next $ addFile Small file s
startSmallOverridden :: DryRun -> SeekInput -> RawFilePath -> CommandStart

View file

@ -519,7 +519,7 @@ addWorkTree _ addunlockedmatcher u url file key mtmp = case mtmp of
-- than the work tree file.
liftIO $ moveFile file tmp
go
else Command.Add.addSmall (DryRun False) file s
else Command.Add.addSmall False (DryRun False) file s
>>= maybe noop void
where
go = do

View file

@ -261,7 +261,7 @@ startLocal o addunlockedmatcher largematcher mode (srcfile, destfile) =
>>= maybe
stop
(\addedk -> next $ Command.Add.cleanup addedk True)
, Command.Add.addSmall (DryRun False) destfile s
, Command.Add.addSmall False (DryRun False) destfile s
)
notoverwriting why = do
warning $ "not overwriting existing " <> QuotedPath destfile <> " " <> UnquotedString why

View file

@ -62,4 +62,4 @@ How to remedy?
dandi project
> Not a bug, [[done]] --[[Joey]]
> [[fixed|done]] --[[Joey]]

View file

@ -1009,8 +1009,8 @@ repository, using [[git-annex-config]]. See its man page for a list.)
* `annex.addsmallfiles`
Controls whether small files (not matching annex.largefiles)
should be checked into git by `git annex add`. Defaults to true;
Controls whether small files (files not matching annex.largefiles, or
dotfiles) should be checked into git by `git annex add`. Defaults to true;
set to false to instead make small files be skipped.
* `annex.addunlocked`