From fb7663ceb86b309dd223ebc113c8b586955a0e03 Mon Sep 17 00:00:00 2001 From: "https://www.google.com/accounts/o8/id?id=AItOawnpdM9F8VbtQ_H5PaPMpGSxPe_d5L1eJ6w" Date: Wed, 29 Jun 2011 14:46:41 +0000 Subject: [PATCH 1/2] --- ..._annex_should_use___39__git_add_-f__39___internally.mdwn | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 doc/bugs/git_annex_should_use___39__git_add_-f__39___internally.mdwn diff --git a/doc/bugs/git_annex_should_use___39__git_add_-f__39___internally.mdwn b/doc/bugs/git_annex_should_use___39__git_add_-f__39___internally.mdwn new file mode 100644 index 0000000000..66b3aa36a3 --- /dev/null +++ b/doc/bugs/git_annex_should_use___39__git_add_-f__39___internally.mdwn @@ -0,0 +1,6 @@ +I have this line in the .gitignore file of one of my repos: +*log + +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. + +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. From b3aaf980e460c2287fc1ef2b262685b1879e6ed0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Jun 2011 11:42:00 -0400 Subject: [PATCH 2/2] --force will cause add, etc, to operate on ignored files. --- Command.hs | 3 ++- Command/Add.hs | 6 +++++- GitRepo.hs | 14 ++++++++------ debian/changelog | 1 + ...ould_use___39__git_add_-f__39___internally.mdwn | 5 +++++ doc/git-annex.mdwn | 3 ++- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Command.hs b/Command.hs index 228c1f40e9..ee81bd0f6f 100644 --- a/Command.hs +++ b/Command.hs @@ -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 diff --git a/Command/Add.hs b/Command/Add.hs index 29a1518e84..5133ee1fd5 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -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 diff --git a/GitRepo.hs b/GitRepo.hs index 9f4a38a5fb..844917b880 100644 --- a/GitRepo.hs +++ b/GitRepo.hs @@ -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] diff --git a/debian/changelog b/debian/changelog index 6439eb89fa..8848cf8611 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Mon, 13 Jun 2011 19:53:24 -0400 diff --git a/doc/bugs/git_annex_should_use___39__git_add_-f__39___internally.mdwn b/doc/bugs/git_annex_should_use___39__git_add_-f__39___internally.mdwn index 66b3aa36a3..a92f5871b5 100644 --- a/doc/bugs/git_annex_should_use___39__git_add_-f__39___internally.mdwn +++ b/doc/bugs/git_annex_should_use___39__git_add_-f__39___internally.mdwn @@ -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]] diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index 12756d8020..177df09527 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -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