add --include-dotfiles: New option, perhaps useful for backups.
This commit is contained in:
parent
6038875ebe
commit
2f538dd65c
6 changed files with 36 additions and 16 deletions
|
@ -30,14 +30,15 @@ withFilesInGit :: (FilePath -> CommandStart) -> CommandSeek
|
||||||
withFilesInGit a params = seekActions $ prepFiltered a $
|
withFilesInGit a params = seekActions $ prepFiltered a $
|
||||||
seekHelper LsFiles.inRepo params
|
seekHelper LsFiles.inRepo params
|
||||||
|
|
||||||
withFilesNotInGit :: (FilePath -> CommandStart) -> CommandSeek
|
withFilesNotInGit :: Bool -> (FilePath -> CommandStart) -> CommandSeek
|
||||||
withFilesNotInGit a params = do
|
withFilesNotInGit skipdotfiles a params
|
||||||
|
| skipdotfiles = do
|
||||||
{- dotfiles are not acted on unless explicitly listed -}
|
{- dotfiles are not acted on unless explicitly listed -}
|
||||||
files <- filter (not . dotfile) <$>
|
files <- filter (not . dotfile) <$>
|
||||||
seekunless (null ps && not (null params)) ps
|
seekunless (null ps && not (null params)) ps
|
||||||
dotfiles <- seekunless (null dotps) dotps
|
dotfiles <- seekunless (null dotps) dotps
|
||||||
seekActions $ prepFiltered a $
|
go (files++dotfiles)
|
||||||
return $ concat $ segmentPaths params (files++dotfiles)
|
| otherwise = go =<< seekunless False params
|
||||||
where
|
where
|
||||||
(dotps, ps) = partition dotfile params
|
(dotps, ps) = partition dotfile params
|
||||||
seekunless True _ = return []
|
seekunless True _ = return []
|
||||||
|
@ -45,6 +46,8 @@ withFilesNotInGit a params = do
|
||||||
force <- Annex.getState Annex.force
|
force <- Annex.getState Annex.force
|
||||||
g <- gitRepo
|
g <- gitRepo
|
||||||
liftIO $ Git.Command.leaveZombie <$> LsFiles.notInRepo force l g
|
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 :: ((FilePath, FilePath) -> CommandStart) -> CommandSeek
|
||||||
withPathContents a params = seekActions $
|
withPathContents a params = seekActions $
|
||||||
|
|
|
@ -34,9 +34,13 @@ import Annex.ReplaceFile
|
||||||
import Utility.Tmp
|
import Utility.Tmp
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [notBareRepo $ command "add" paramPaths seek SectionCommon
|
def = [notBareRepo $ withOptions [includeDotFilesOption] $
|
||||||
|
command "add" paramPaths seek SectionCommon
|
||||||
"add files to annex"]
|
"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.
|
{- Add acts on both files not checked into git yet, and unlocked files.
|
||||||
-
|
-
|
||||||
- In direct mode, it acts on any files that have changed. -}
|
- In direct mode, it acts on any files that have changed. -}
|
||||||
|
@ -47,7 +51,8 @@ seek ps = do
|
||||||
( start file
|
( start file
|
||||||
, stop
|
, stop
|
||||||
)
|
)
|
||||||
go withFilesNotInGit
|
skipdotfiles <- not <$> Annex.getFlag (optionName includeDotFilesOption)
|
||||||
|
go $ withFilesNotInGit skipdotfiles
|
||||||
ifM isDirect
|
ifM isDirect
|
||||||
( go withFilesMaybeModified
|
( go withFilesMaybeModified
|
||||||
, go withFilesUnlocked
|
, go withFilesUnlocked
|
||||||
|
|
|
@ -36,7 +36,7 @@ check = do
|
||||||
|
|
||||||
seek :: CommandSeek
|
seek :: CommandSeek
|
||||||
seek ps = do
|
seek ps = do
|
||||||
withFilesNotInGit (whenAnnexed startCheckIncomplete) ps
|
withFilesNotInGit False (whenAnnexed startCheckIncomplete) ps
|
||||||
withFilesInGit (whenAnnexed Command.Unannex.start) ps
|
withFilesInGit (whenAnnexed Command.Unannex.start) ps
|
||||||
finish
|
finish
|
||||||
|
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -19,6 +19,7 @@ git-annex (5.20140321) UNRELEASED; urgency=medium
|
||||||
a remote git repository, as long as a git-annex branch has
|
a remote git repository, as long as a git-annex branch has
|
||||||
been pushed to it, to simplify setup of remote git repositories,
|
been pushed to it, to simplify setup of remote git repositories,
|
||||||
including via gitolite.
|
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
|
-- Joey Hess <joeyh@debian.org> Fri, 21 Mar 2014 14:08:41 -0400
|
||||||
|
|
||||||
|
|
|
@ -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.
|
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."
|
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]]
|
||||||
|
|
|
@ -62,10 +62,14 @@ subdirectories).
|
||||||
|
|
||||||
* `add [path ...]`
|
* `add [path ...]`
|
||||||
|
|
||||||
Adds files in the path to the annex. Files that are already checked into
|
Adds files in the path to the annex. If no path is specified, adds
|
||||||
git, or that git has been configured to ignore will be silently skipped.
|
files from the current directory and below.
|
||||||
(Use `--force` to add ignored files.) Dotfiles are skipped unless explicitly
|
|
||||||
listed.
|
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 ...]`
|
* `get [path ...]`
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue