add: If annex.largefiles is set and does not match a file that's being added, the file will be checked into git rather than being added to the annex. Previously, git annex add skipped over such files; this new behavior is more useful in direct mode.

This commit is contained in:
Joey Hess 2015-04-08 16:14:23 -04:00
parent 279fa44cd0
commit 4da371af1e
3 changed files with 26 additions and 5 deletions

View file

@ -52,7 +52,7 @@ seek ps = do
matcher <- largeFilesMatcher matcher <- largeFilesMatcher
let go a = flip a ps $ \file -> ifM (checkFileMatcher matcher file <||> Annex.getState Annex.force) let go a = flip a ps $ \file -> ifM (checkFileMatcher matcher file <||> Annex.getState Annex.force)
( start file ( start file
, stop , startSmall file
) )
skipdotfiles <- not <$> Annex.getFlag (optionName includeDotFilesOption) skipdotfiles <- not <$> Annex.getFlag (optionName includeDotFilesOption)
go $ withFilesNotInGit skipdotfiles go $ withFilesNotInGit skipdotfiles
@ -61,6 +61,16 @@ seek ps = do
, go withFilesUnlocked , go withFilesUnlocked
) )
{- Pass file off to git-add. -}
startSmall :: FilePath -> CommandStart
startSmall file = do
showStart "add" file
showNote "non-large file; adding to git directly"
next $ do
params <- forceParams
Annex.Queue.addCommand "add" (params++[Param "--"]) [file]
next $ return True
{- The add subcommand annexes a file, generating a key for it using a {- The add subcommand annexes a file, generating a key for it using a
- backend, and then moving it into the annex directory and setting up - backend, and then moving it into the annex directory and setting up
- the symlink pointing to its content. -} - the symlink pointing to its content. -}
@ -260,16 +270,19 @@ addLink :: FilePath -> Key -> Maybe InodeCache -> Annex ()
addLink file key mcache = ifM (coreSymlinks <$> Annex.getGitConfig) addLink file key mcache = ifM (coreSymlinks <$> Annex.getGitConfig)
( do ( do
_ <- link file key mcache _ <- link file key mcache
params <- ifM (Annex.getState Annex.force) params <- forceParams
( return [Param "-f"]
, return []
)
Annex.Queue.addCommand "add" (params++[Param "--"]) [file] Annex.Queue.addCommand "add" (params++[Param "--"]) [file]
, do , do
l <- link file key mcache l <- link file key mcache
addAnnexLink l file addAnnexLink l file
) )
forceParams :: Annex [CommandParam]
forceParams = ifM (Annex.getState Annex.force)
( return [Param "-f"]
, return []
)
cleanup :: FilePath -> Key -> Maybe InodeCache -> Bool -> CommandCleanup cleanup :: FilePath -> Key -> Maybe InodeCache -> Bool -> CommandCleanup
cleanup file key mcache hascontent = do cleanup file key mcache hascontent = do
ifM (isDirect <&&> pure hascontent) ifM (isDirect <&&> pure hascontent)

4
debian/changelog vendored
View file

@ -4,6 +4,10 @@ git-annex (5.20150406.2) UNRELEASED; urgency=medium
(Second time's the charm..) (Second time's the charm..)
* fromkey, registerurl: When reading from stdin, allow the * fromkey, registerurl: When reading from stdin, allow the
filename and url, respectively, to contain whitespace. filename and url, respectively, to contain whitespace.
* add: If annex.largefiles is set and does not match a file that's being
added, the file will be checked into git rather than being added to the
annex. Previously, git annex add skipped over such files; this new
behavior is more useful in direct mode.
-- Joey Hess <id@joeyh.name> Mon, 06 Apr 2015 20:14:20 -0400 -- Joey Hess <id@joeyh.name> Mon, 06 Apr 2015 20:14:20 -0400

View file

@ -14,6 +14,10 @@ files from the current directory and below.
Normally, files that are already checked into git, or that git has been Normally, files that are already checked into git, or that git has been
configured to ignore will be silently skipped. configured to ignore will be silently skipped.
If annex.largefiles is configured, and does not match a file that is being
added, `git annex add` will behave the same as `git add` and add the
non-large file directly to the git repository, instead of to the annex.
# OPTIONS # OPTIONS
* `--include-dotfiles` * `--include-dotfiles`