diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-04-07 15:55:34 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-04-07 15:55:45 -0400 |
commit | ad6f647124993f102b18f1390c89df3f0db5e3d5 (patch) | |
tree | fc6767048d4bfc4a39fcc8dc199162a4be75dc5f /Command | |
parent | e1e52ab130e4a67d001e0577010f8cd142860914 (diff) |
git annex add -u now supported, analagous to git add -u
Unlike git add -u, git annex add -u does not update the index for files
removed from the working tree. But then, "git add ." stages removals,
and "git annex add ." does not, so that's an existing divergence.
Seems that --update --batch would need to run git ls-files once per line of
batch input, which would surely be too slow, so just throw an error for
that.
This commit was supported by the NSF-funded DataLad project.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Add.hs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Command/Add.hs b/Command/Add.hs index f9cfbb9a1..beea48e0b 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -1,6 +1,6 @@ {- git-annex command - - - Copyright 2010, 2013 Joey Hess <id@joeyh.name> + - Copyright 2010-2017 Joey Hess <id@joeyh.name> - - Licensed under the GNU GPL version 3 or higher. -} @@ -30,6 +30,7 @@ data AddOptions = AddOptions { addThese :: CmdParams , includeDotFiles :: Bool , batchOption :: BatchMode + , updateOnly :: Bool } optParser :: CmdParamsDesc -> Parser AddOptions @@ -40,6 +41,11 @@ optParser desc = AddOptions <> help "don't skip dotfiles" ) <*> parseBatchOption + <*> switch + ( long "update" + <> short 'u' + <> help "only update tracked files" + ) seek :: AddOptions -> CommandSeek seek o = allowConcurrentOutput $ do @@ -52,10 +58,14 @@ seek o = allowConcurrentOutput $ do ) ) case batchOption o of - Batch -> batchFiles gofile + Batch + | updateOnly o -> + giveup "--update --batch is not supported" + | otherwise -> batchFiles gofile NoBatch -> do let go a = a gofile (addThese o) - go (withFilesNotInGit (not $ includeDotFiles o)) + unless (updateOnly o) $ + go (withFilesNotInGit (not $ includeDotFiles o)) go withFilesMaybeModified unlessM (versionSupportsUnlockedPointers <||> isDirect) $ go withFilesOldUnlocked |