I'm looking to improve my gitinfo package by reducing the amount of setup needed.
For this, I want to be able to search for a file in the current directory, then the parent, then the grandparent ... until either (a) I find the file [OK] or (b) find a directory called .git [Error message a] or (c) fall off the top of the file system tree [Error message b].
I've tried nesting \InputIfFileExists, but that only gives me a fixed maximum number of levels.
Sorry, I really don't have a clue as to the simplest approach; so pointers to useful packages to use or copy would be a good option, rather than predigested answers (though these, obviously, would be very welcome).
Having done a little more reading, finding a directory might be a bit more difficult, so finding a file .git/description would do.
.tex. I believe this is doable withpdftexandluatex, but not withxetexunless shell escape is enabled. Checking whether we are at the top might be tougher, because Unix system allowcd ..when at the top. – egreg Feb 13 '13 at 14:27.gitdirectory, but that's not what I call a quality solution. Thanks anyway... – Brent.Longborough Feb 13 '13 at 16:51pdftexone can do\pdffilemoddatethat expands to something if the file exists and to nothing if the file doesn't exist. The loop might end after a big, although finite, number of steps: 255 levels before reaching the top of the file system should be sufficient. – egreg Feb 13 '13 at 16:56