diff options
-rw-r--r-- | CmdLine/Seek.hs | 19 | ||||
-rw-r--r-- | Command/Add.hs | 11 | ||||
-rw-r--r-- | Command/Uninit.hs | 2 | ||||
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | doc/bugs/Feature_request:_Flag_to_make_git_annex_add_not_ignore_dotfiles.mdwn | 7 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 12 |
6 files changed, 36 insertions, 16 deletions
diff --git a/CmdLine/Seek.hs b/CmdLine/Seek.hs index e95b9f005..abbe52af8 100644 --- a/CmdLine/Seek.hs +++ b/CmdLine/Seek.hs @@ -30,14 +30,15 @@ withFilesInGit :: (FilePath -> CommandStart) -> CommandSeek withFilesInGit a params = seekActions $ prepFiltered a $ seekHelper LsFiles.inRepo params -withFilesNotInGit :: (FilePath -> CommandStart) -> CommandSeek -withFilesNotInGit a params = do - {- dotfiles are not acted on unless explicitly listed -} - files <- filter (not . dotfile) <$> - seekunless (null ps && not (null params)) ps - dotfiles <- seekunless (null dotps) dotps - seekActions $ prepFiltered a $ - return $ concat $ segmentPaths params (files++dotfiles) +withFilesNotInGit :: Bool -> (FilePath -> CommandStart) -> CommandSeek +withFilesNotInGit skipdotfiles a params + | skipdotfiles = do + {- dotfiles are not acted on unless explicitly listed -} + files <- filter (not . dotfile) <$> + seekunless (null ps && not (null params)) ps + dotfiles <- seekunless (null dotps) dotps + go (files++dotfiles) + | otherwise = go =<< seekunless False params where (dotps, ps) = partition dotfile params seekunless True _ = return [] @@ -45,6 +46,8 @@ withFilesNotInGit a params = do force <- Annex.getState Annex.force g <- gitRepo liftIO $ Git.Command.leaveZombie <$> LsFiles.notInRepo force l g + go l = seekActions $ prepFiltered a $ + return $ concat $ segmentPaths params l withPathContents :: ((FilePath, FilePath) -> CommandStart) -> CommandSeek withPathContents a params = seekActions $ diff --git a/Command/Add.hs b/Command/Add.hs index 0c8e2a48d..f9e2b3342 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -34,8 +34,12 @@ import Annex.ReplaceFile import Utility.Tmp def :: [Command] -def = [notBareRepo $ command "add" paramPaths seek SectionCommon - "add files to annex"] +def = [notBareRepo $ withOptions [includeDotFilesOption] $ + command "add" paramPaths seek SectionCommon + "add files to annex"] + +includeDotFilesOption :: Option +includeDotFilesOption = flagOption [] "include-dotfiles" "don't skip dotfiles" {- Add acts on both files not checked into git yet, and unlocked files. - @@ -47,7 +51,8 @@ seek ps = do ( start file , stop ) - go withFilesNotInGit + skipdotfiles <- not <$> Annex.getFlag (optionName includeDotFilesOption) + go $ withFilesNotInGit skipdotfiles ifM isDirect ( go withFilesMaybeModified , go withFilesUnlocked diff --git a/Command/Uninit.hs b/Command/Uninit.hs index 2a9e3e687..5b2adf0bd 100644 --- a/Command/Uninit.hs +++ b/Command/Uninit.hs @@ -36,7 +36,7 @@ check = do seek :: CommandSeek seek ps = do - withFilesNotInGit (whenAnnexed startCheckIncomplete) ps + withFilesNotInGit False (whenAnnexed startCheckIncomplete) ps withFilesInGit (whenAnnexed Command.Unannex.start) ps finish diff --git a/debian/changelog b/debian/changelog index eee5509ba..f237f019d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,6 +19,7 @@ git-annex (5.20140321) UNRELEASED; urgency=medium a remote git repository, as long as a git-annex branch has been pushed to it, to simplify setup of remote git repositories, including via gitolite. + * add --include-dotfiles: New option, perhaps useful for backups. -- Joey Hess <joeyh@debian.org> Fri, 21 Mar 2014 14:08:41 -0400 diff --git a/doc/bugs/Feature_request:_Flag_to_make_git_annex_add_not_ignore_dotfiles.mdwn b/doc/bugs/Feature_request:_Flag_to_make_git_annex_add_not_ignore_dotfiles.mdwn index f82d8835f..686bf1887 100644 --- a/doc/bugs/Feature_request:_Flag_to_make_git_annex_add_not_ignore_dotfiles.mdwn +++ b/doc/bugs/Feature_request:_Flag_to_make_git_annex_add_not_ignore_dotfiles.mdwn @@ -5,3 +5,10 @@ AFAICT there's no way to tell git annex add to add all dotfiles in a given direc This can be worked around with find and xargs, but this is more work than it should be, I think. It might also be nice if git annex add displayed a warning when adding a directory with dotfiles; something like "Warning, N files ignored; pass --whatever to add them." + +> [[!commit 34abd7bca80a8cc012f92d64116014449b1b2392]] explains +> the rationalle for dotfiles to be skipped. Such as it was. +> +> I don't think it makes sense for --force to be the flag to override +> this, because you may want to add dotfiles, but not .gitignored +> files. So, made a new --include-dotfiles option. [[done]] --[[Joey]] diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index a1005cbc8..6e9f39826 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -62,10 +62,14 @@ subdirectories). * `add [path ...]` - Adds files in the path to the annex. Files that are already checked into - git, or that git has been configured to ignore will be silently skipped. - (Use `--force` to add ignored files.) Dotfiles are skipped unless explicitly - listed. + Adds files in the path to the annex. If no path is specified, adds + files from the current directory and below. + + Files that are already checked into git, or that git has been configured + to ignore will be silently skipped. (Use `--force` to add ignored files.) + + Dotfiles are skipped unless explicitly listed, or the --include-dotfiles + option is used. * `get [path ...]` |