git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Determining if a file exists in a bare repo

From
Jacob Helwig <jacob.helwig@gmail.com>
Date
May 4, 2010, 16:18 UTC
Message-ID
<h2z8c9a061005040918s33bd5020sa89e95aedb7b8cb@mail.gmail.com>
In-Reply-To
<w2q799406d61005040911p8fd7c234s5e6382298129985f@mail.gmail.com>
On Tue, May 4, 2010 at 09:11, Adam Mercer <ramercer@gmail.com> wrote:
Show 28 quoted lines
> 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?
Previous: Adam MercerNext: Adam Mercer
Message 2 of 5 in “Determining if a file exists in a bare repo”
  1. Adam MercerMay 4, 2010
  2. Jacob HelwigMay 4, 2010
  3. Adam MercerMay 4, 2010
  4. Junio C HamanoMay 4, 2010
  5. Adam MercerMay 4, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.