Please describe the problem.
When attempting to add a file listed in .gitignore, git annex exits silently. I would expect to see an error message a la plain git: "The following paths are ignored by one of your .gitignore files: that file"
What steps will reproduce the problem?
- Add a file to .gitignore
- git annex add that file
What version of git-annex are you using? On what operating system?
git-annex version: 6.20160613 build flags: Assistant Webapp Pairing Testsuite S3(multipartupload)(storageclasses) WebDAV FsEvents XMPP ConcurrentOutput TorrentParser MagicMime Feeds Quvi key/value backends: SHA256E SHA256 SHA512E SHA512 SHA224E SHA224 SHA384E SHA384 SHA3_256E SHA3_256 SHA3_512E SHA3_512 SHA3_224E SHA3_224 SHA3_384E SHA3_384 SKEIN256E SKEIN256 SKEIN512E SKEIN512 SHA1E SHA1 MD5E MD5 WORM URL remote types: git gcrypt S3 bup directory rsync web bittorrent webdav tahoe glacier ddar hook external local repository version: 5 supported repository versions: 5 6 upgrade supported from repository versions: 0 1 2 3 4 5 operating system: darwin x86_64
Please provide any additional information below.
# If you can, paste a complete transcript of the problem occurring here.
# If the problem is with the git-annex assistant, paste in .git/annex/daemon.log
# End of transcript or log.
This is due to git-annex using
git ls-files --others --exclude-standard
to find files to add. Since that silently skips ignored files, so does git-annex.Now that git has
git check-ignore --stdin
, it would be possible for git-annex to not rungit ls-files
with--exclude-standard
, and instead check each file it returns to see if it's ignored, and print out a warning message.But, that would mean a round-trip through the pipe for each filename. When operating on a directory containing a lot of new files, it would probably slow down the processing somewhat.
Hmm, but,
git add somedir
does not warn if there are gitignored files in somedir; it silently skips them while adding the rest of the directory. The warning comes only when explicitly listing an ignored file.So, git-annex could do the same, only passing the filename through checkingnore when it's a normal file and not a directory. This does entail statting every command-line parameter though, and passing through checkignore would still slow things down. Particularly when
git annex add
is run with a huge list of files to add.I don't know if it's super-important for
git annex add
to mirror every behavior ofgit add
anyway. Other differences includegit annex add
with no parameters defaulting to adding ".", andgit annex add
skipping dotfiles by default.In v6 mode, you can use
git add
to do the same thing asgit annex add
, only more slowly. So it could be argued thatgit annex add
will remain separate fromgit add
only because its different behavior can be more useful, and for performance reasons. Which makes slowinggit annex add
down in order to make it behave more likegit add
seem counterproductive.Perhaps other people knew this already, but I thought I would post it here in case someone else has trouble finding a solution to this issue.
I use a global gitignore that ignores most of the files I want to have in my annex. The solution was to override my global .gitignore according to this answer at SO http://stackoverflow.com/questions/26678955/un-ignore-all-files-in-global-gitignore by creating a .gitignore in the annexed repo with the pattern
!*
Now it automatically adds everything (except dotfiles) when running
git annex add $DIRPATH
.