I've been trying to get all image files added to git annex with a wildcard, with no luck. If I use 'git annex add image.jpg', the file gets added and I can commit it. Also using 'git annex add .' works for adding all files.
Comands I've tried-
git annex add *.jpg * This outputs to the screen that it's adding each .jpg it finds, but when I go to commit there are 0 files staged.
git annex add . --include='*.jpg' * This doesn't return any results.
What command should I be using on a Mac to just add all files with a specific extension?
There is no difference between "git annex add *" and "git annex add list of files". The wildcard is expanded by your shell, not by git-annex.
Post a transcript of the problem.
So if I drill all the way down into a folder containing images, the git annex add and git commit are successful. When trying to do the same from the root of the site, I get the add messages, but nothing appears to be staged when committing.
Here is the output when trying to add all images recursively from the root of the site
Here is the successful output when I run the same commands from a subfolder
The shell does not expand *.jpg to match files inside subdirectories.
I suggest you read up on how shell wildcards work, and how to use them properly.
There is a bit of a bug here, which is that the shell, when
*.jpg
does not expand to anything, passes the"*.jpg"
parameter to git-annex un-expanded, which then passes it off to git ls-files, which then unexpectedly expands it to recursively match jpegs in subirectories. Only then does git-annex try to add a*.jpg
file, and when it doesn't exist, it exits with an error, leaving the files it did add unstaged in git.To get out of that situation, just re-run git-annex add and actually list the files or directories to add, rather than a wildcard that won't expand to them..
I'll see if I can fix the behavior here, it should just fail when given an un-expanded wildcard.
I've fixed this; now you'll see:
The fix is a regression compared to previous behavior.
Being able to do
git annex add '*'.{JPG,jp{,e}g,AVI,avi,MOV,mov,3GP,3gp,mp4,tif,pdf,PDF,doc,pps,bmp,png,mp{,e}g,MP{,E}G,wav,WAV,nef,NEF,thm,THM,key.gz,ogg,OGG,ppt,GIF,gif,m4a}
in the root of my binary files archive to catch any newly copied files was a real feature. This worked until recently. I was just about to add a bug report stating the same problem as the OP for the OSX homebrew version, but I verified with the latest Linux standalone and there wildcards were completely turned off.This is a workaround to the missing functionality, generating an
--include
expression:The old behavior was accidental, and was never documented. When you use such undocumented behaviors, you're taking the risk of bugfixes breaking things. It's not fair to call that a "regression". If I had to worry about every bugfix breaking users who relied on the old buggy behavior in some way, I could just stop working now.
It might be reasonable to add the "expand wildcards rather than letting the shell do it" feature, as an option. Of course, it would need to be tested for every git-annex command and problems like the one that caused this bug to be noticed in the first place dealt with, for every git-annex command. Using --include and --exclude, which already work seems pretty reasonable instead.