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:
parent
876d5b6c6f
commit
b94221594b
6 changed files with 24 additions and 19 deletions
|
@ -5,6 +5,8 @@ git-annex (10.20241032) UNRELEASED; urgency=medium
|
||||||
* vpop: Only update state after successful checkout.
|
* vpop: Only update state after successful checkout.
|
||||||
* add: Consistently treat files in a dotdir as dotfiles, even
|
* add: Consistently treat files in a dotdir as dotfiles, even
|
||||||
when ran inside that dotdir.
|
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
|
-- Joey Hess <id@joeyh.name> Mon, 11 Nov 2024 12:26:00 -0400
|
||||||
|
|
||||||
|
|
|
@ -95,18 +95,20 @@ seek' o = do
|
||||||
annexdotfiles <- getGitConfigVal annexDotFiles
|
annexdotfiles <- getGitConfigVal annexDotFiles
|
||||||
let gofile includingsmall (si, file) = case largeFilesOverride o of
|
let gofile includingsmall (si, file) = case largeFilesOverride o of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
topfile <- getTopFilePath <$> inRepo (toTopFilePath file)
|
isdotfile <- if annexdotfiles
|
||||||
ifM (pure (annexdotfiles || not (dotfile topfile))
|
then pure False
|
||||||
<&&> (checkFileMatcher NoLiveUpdate largematcher file
|
else dotfile . getTopFilePath
|
||||||
<||> Annex.getRead Annex.force))
|
<$> inRepo (toTopFilePath file)
|
||||||
( start dr si file addunlockedmatcher
|
islarge <- checkFileMatcher NoLiveUpdate largematcher file
|
||||||
, if includingsmall
|
<||> Annex.getRead Annex.force
|
||||||
|
if (not isdotfile && islarge)
|
||||||
|
then start dr si file addunlockedmatcher
|
||||||
|
else if includingsmall
|
||||||
then ifM (annexAddSmallFiles <$> Annex.getGitConfig)
|
then ifM (annexAddSmallFiles <$> Annex.getGitConfig)
|
||||||
( startSmall dr si file
|
( startSmall isdotfile dr si file
|
||||||
, stop
|
, stop
|
||||||
)
|
)
|
||||||
else stop
|
else stop
|
||||||
)
|
|
||||||
Just True -> start dr si file addunlockedmatcher
|
Just True -> start dr si file addunlockedmatcher
|
||||||
Just False -> startSmallOverridden dr si file
|
Just False -> startSmallOverridden dr si file
|
||||||
case batchOption o of
|
case batchOption o of
|
||||||
|
@ -138,17 +140,18 @@ seek' o = do
|
||||||
dr = dryRunOption o
|
dr = dryRunOption o
|
||||||
|
|
||||||
{- Pass file off to git-add. -}
|
{- Pass file off to git-add. -}
|
||||||
startSmall :: DryRun -> SeekInput -> RawFilePath -> CommandStart
|
startSmall :: Bool -> DryRun -> SeekInput -> RawFilePath -> CommandStart
|
||||||
startSmall dr si file =
|
startSmall isdotfile dr si file =
|
||||||
liftIO (catchMaybeIO $ R.getSymbolicLinkStatus file) >>= \case
|
liftIO (catchMaybeIO $ R.getSymbolicLinkStatus file) >>= \case
|
||||||
Just s ->
|
Just s ->
|
||||||
starting "add" (ActionItemTreeFile file) si $
|
starting "add" (ActionItemTreeFile file) si $
|
||||||
addSmall dr file s
|
addSmall isdotfile dr file s
|
||||||
Nothing -> stop
|
Nothing -> stop
|
||||||
|
|
||||||
addSmall :: DryRun -> RawFilePath -> FileStatus -> CommandPerform
|
addSmall :: Bool -> DryRun -> RawFilePath -> FileStatus -> CommandPerform
|
||||||
addSmall dr file s = do
|
addSmall isdotfile dr file s = do
|
||||||
showNote "non-large file; adding content to git repository"
|
showNote $ (if isdotfile then "dotfile" else "non-large file")
|
||||||
|
<> "; adding content to git repository"
|
||||||
skipWhenDryRun dr $ next $ addFile Small file s
|
skipWhenDryRun dr $ next $ addFile Small file s
|
||||||
|
|
||||||
startSmallOverridden :: DryRun -> SeekInput -> RawFilePath -> CommandStart
|
startSmallOverridden :: DryRun -> SeekInput -> RawFilePath -> CommandStart
|
||||||
|
|
|
@ -519,7 +519,7 @@ addWorkTree _ addunlockedmatcher u url file key mtmp = case mtmp of
|
||||||
-- than the work tree file.
|
-- than the work tree file.
|
||||||
liftIO $ moveFile file tmp
|
liftIO $ moveFile file tmp
|
||||||
go
|
go
|
||||||
else Command.Add.addSmall (DryRun False) file s
|
else Command.Add.addSmall False (DryRun False) file s
|
||||||
>>= maybe noop void
|
>>= maybe noop void
|
||||||
where
|
where
|
||||||
go = do
|
go = do
|
||||||
|
|
|
@ -261,7 +261,7 @@ startLocal o addunlockedmatcher largematcher mode (srcfile, destfile) =
|
||||||
>>= maybe
|
>>= maybe
|
||||||
stop
|
stop
|
||||||
(\addedk -> next $ Command.Add.cleanup addedk True)
|
(\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
|
notoverwriting why = do
|
||||||
warning $ "not overwriting existing " <> QuotedPath destfile <> " " <> UnquotedString why
|
warning $ "not overwriting existing " <> QuotedPath destfile <> " " <> UnquotedString why
|
||||||
|
|
|
@ -62,4 +62,4 @@ How to remedy?
|
||||||
|
|
||||||
dandi project
|
dandi project
|
||||||
|
|
||||||
> Not a bug, [[done]] --[[Joey]]
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
|
@ -1009,8 +1009,8 @@ repository, using [[git-annex-config]]. See its man page for a list.)
|
||||||
|
|
||||||
* `annex.addsmallfiles`
|
* `annex.addsmallfiles`
|
||||||
|
|
||||||
Controls whether small files (not matching annex.largefiles)
|
Controls whether small files (files not matching annex.largefiles, or
|
||||||
should be checked into git by `git annex add`. Defaults to true;
|
dotfiles) should be checked into git by `git annex add`. Defaults to true;
|
||||||
set to false to instead make small files be skipped.
|
set to false to instead make small files be skipped.
|
||||||
|
|
||||||
* `annex.addunlocked`
|
* `annex.addunlocked`
|
||||||
|
|
Loading…
Add table
Reference in a new issue