A script which just wants a lean copy of the current state from the server to process further does this as an alternative to a shallow clone:
git archive --remote=ssh://example.com/repo.git --output=repo.tar.gz HEAD -- "*.hpp" "*.cpp" "*.inc"
If that repo happens to not have files for one of the wildcards, the whole operation fails:
remote: fatal: pathspec '*.inc' did not match any files
fatal: sent error to the client: git upload-archive: archiver died with error
remote: git upload-archive: archiver died with error
Is there a generic way to ignore certain pathspecs if they would throw an error otherwise? Without such filter it downloads just too much.
There are patterns in pathspecs including 'glob', but I couldn't find out how to make a logical "OR" or a regular expression.