Determining if a file exists in a bare repo
- From
Adam Mercer <ramercer@gmail.com>
- Date
- May 4, 2010, 16:11 UTC
- Message-ID
- <w2q799406d61005040911p8fd7c234s5e6382298129985f@mail.gmail.com>
Hi
I'm trying to write a post-receive hook that generates some HTML files from reStructured text files stored in a repository. Essentially I'm doing this with
git show master:INSTALL | rst2html --no-raw --no-file-insertion > /path/to/INSTALL.html
However I would like this script to fail gracefully if the INSTALL file is not available in the repository so would like to check if this file exists. The problem I'm having is that git-show seems to return a zero return code even if the file you request doesn't exist, e.g.:
$ git show master:NoneExistantFile fatal: ambiguous argument 'master:NoneExistantFile': unknown revision or path not in the working tree. Use '--' to separate paths from revisions $ echo $? 0 $
is there another, scriptable, way to determine if a given file exists in a given branch of a bare repository?
Cheers
Adam