From: Jacob Helwig Date: Tue, 04 May 2010 16:18:09 GMT Subject: Re: Determining if a file exists in a bare repo Message-ID: In-Reply-To: On Tue, May 4, 2010 at 09:11, Adam Mercer wrote: > 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 What about using "git ls-tree master" to get a file listing?