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

Re: Is "show-ref -h" a good test for an empty repository?

From
Jeff King <peff@peff.net>
Date
Sep 6, 2008, 01:29 UTC
Message-ID
<20080906012941.GA2009@coredump.intra.peff.net>
In-Reply-To
<48C1D2AE.3010001@feds.uwaterloo.ca>
On Fri, Sep 05, 2008 at 08:45:34PM -0400, Eric Gerlach wrote:
Show 8 quoted lines
> I'm trying to test to see if "git diff --cached" will fail because there  
> are no existing commits.  I've come up with running "git show-ref -h -q"  
> and testing its return value.  My hypothesis is: If and only if  
> git-show-ref succeeds then git-diff will succeed.
>
> Are my logic and assumptions sound?  I'm a bit out of my git comfort zone 
> here, so I'd like to get some validation from some people who know  
> better.
Maybe "git rev-parse --verify HEAD"?
-Peff
Previous: Eric GerlachNext: Eric Gerlach
Message 2 of 8 in “Is "show-ref -h" a good test for an empty repository?”
  1. Eric GerlachSep 6, 2008
  2. Jeff KingSep 6, 2008
  3. Eric GerlachSep 7, 2008
  4. Jeff KingSep 7, 2008
  5. Junio C HamanoSep 7, 2008
  6. Jeff KingSep 7, 2008
  7. Eric GerlachSep 8, 2008
  8. Jeff KingSep 8, 2008

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.