Re: Determining if a file exists in a bare repo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Adam Mercer <ramercer@xxxxxxxxx> writes:

> 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

Even if it returned an error status, you are discarding it by placing the
process on the upstream side of the pipe, so your command line above won't
be able to catch an error anyway.  I would probably do something like this
if I were you:

    git rev-parse --verify master:INSTALL >/dev/null 2>&1 &&
    git cat-file blob master:INSTALL | rst2...
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]