--force will cause add, etc, to operate on ignored files.

This commit is contained in:
Joey Hess 2011-06-29 11:42:00 -04:00
parent fb7663ceb8
commit b3aaf980e4
6 changed files with 23 additions and 9 deletions

View file

@ -143,7 +143,8 @@ withFilesMissing a params = do
withFilesNotInGit :: CommandSeekBackendFiles
withFilesNotInGit a params = do
repo <- Annex.gitRepo
newfiles <- liftIO $ runPreserveOrder (Git.notInRepo repo) params
force <- Annex.getState Annex.force
newfiles <- liftIO $ runPreserveOrder (Git.notInRepo repo force) params
newfiles' <- filterFiles newfiles
backendPairs a newfiles'
withWords :: CommandSeekWords

View file

@ -11,6 +11,7 @@ import Control.Monad.State (liftIO)
import System.Posix.Files
import Command
import qualified Annex
import qualified AnnexQueue
import qualified Backend
import LocationLog
@ -60,5 +61,8 @@ cleanup file key = do
let mtime = modificationTime s
liftIO $ touch file (TimeSpec mtime) False
AnnexQueue.add "add" [Param "--"] file
force <- Annex.getState Annex.force
if force
then AnnexQueue.add "add" [Param "-f", Param "--"] file
else AnnexQueue.add "add" [Param "--"] file
return True

View file

@ -382,13 +382,15 @@ reap = do
{- Scans for files that are checked into git at the specified locations. -}
inRepo :: Repo -> [FilePath] -> IO [FilePath]
inRepo repo l = pipeNullSplit repo $
[Params "ls-files --cached --exclude-standard -z --"] ++ map File l
[Params "ls-files --cached -z --"] ++ map File l
{- Scans for files at the specified locations that are not checked into git,
- and not gitignored. -}
notInRepo :: Repo -> [FilePath] -> IO [FilePath]
notInRepo repo l = pipeNullSplit repo $
[Params "ls-files --others --exclude-standard -z --"] ++ map File l
{- Scans for files at the specified locations that are not checked into
- git. -}
notInRepo :: Repo -> Bool -> [FilePath] -> IO [FilePath]
notInRepo repo include_ignored l =
pipeNullSplit repo $ [Params "ls-files --others"]++exclude++[Params "-z --"] ++ map File l
where
exclude = if include_ignored then [] else [Param "--exclude-standard"]
{- Returns a list of all files that are staged for commit. -}
stagedFiles :: Repo -> [FilePath] -> IO [FilePath]

1
debian/changelog vendored
View file

@ -9,6 +9,7 @@ git-annex (0.20110611) UNRELEASED; urgency=low
* unlock: Made atomic.
* git-union-merge: New git subcommand, that does a generic union merge
operation, and operates efficiently without touching the working tree.
* --force will cause add, etc, to operate on ignored files.
-- Joey Hess <joeyh@debian.org> Mon, 13 Jun 2011 19:53:24 -0400

View file

@ -3,4 +3,9 @@ I have this line in the .gitignore file of one of my repos:
So the command 'git annex init name' fails to add the file ".git-annex/uuid.log", and the same problem happens when git-annex-add'ing files.
> This is avoided on the v3 branch, which does not store these files in the
> same branch as your repository.
Also, when a file is git-ignored, it should be possible to 'git annex add' it with a -f/--force option, the same way git does it.
> Reasonable, [[done]] --[[Joey]]

View file

@ -314,7 +314,8 @@ Many git-annex commands will stage changes for later `git commit` by you.
* --force
Force unsafe actions, such as dropping a file's content when no other
source of it can be verified to still exist. Use with care.
source of it can be verified to still exist, or adding ignored files.
Use with care.
* --fast