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

[RFC] improve 'bad default revision' message for empty repo

From
Jeff King <peff@peff.net>
Date
Mar 5, 2008, 01:07 UTC
Message-ID
<20080305010701.GB20007@sigill.intra.peff.net>
In-Reply-To
<3f4fd2640803041351k6debe788xbf5e818951f70146@mail.gmail.com>
On Tue, Mar 04, 2008 at 09:51:02PM +0000, Reece Dunn wrote:
Show 11 quoted lines
> >  > Consider the following workflow:
> >  >
> >  >     $ mkdir foo
> >  >     $ cd foo
> >  >     $ git --bare init
> >  >
> >  >     $ git log
> >  >     fatal: bad default revision 'HEAD'
> >  >
> >  > This message is confusing for a newbie. Displaying "no commits" would
> >  > make more sense here.

What do people think of this patch? It feels a little hack-ish to make guesses as to the reasons for a failure, but in my experience an empty repo is the cause of this message in 99% of cases.

We could special-case it to HEAD and make a better message, perhaps, but that feels even more hack-ish.

---
 revision.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/revision.c b/revision.c
index 63bf2c5..847dbc8 100644
--- a/revision.c
+++ b/revision.c
@@ -1324,7 +1324,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 		struct object *object;
 		unsigned mode;
 		if (get_sha1_with_mode(def, sha1, &mode))
-			die("bad default revision '%s'", def);
+			die("unable to resolve '%s'; do you have any commits on this branch?", def);
 		object = get_reference(revs, def, sha1, 0);
 		add_pending_object_with_mode(revs, object, def, mode);
 	}
-- 
1.5.4.3.531.ga940.dirty
Previous: Reece DunnNext: Junio C Hamano
Message 4 of 9 in “Some issues working with empty/bare repositories...”
  1. Reece DunnMar 1, 2008
  2. Jeff KingMar 3, 2008
  3. Reece DunnMar 4, 2008
  4. [RFC] improve 'bad default revision' message for empty repoJeff King, Mar 5, 2008
  5. Junio C HamanoMar 5, 2008
  6. Jeff KingMar 5, 2008
  7. Junio C HamanoMar 5, 2008
  8. Jeff KingMar 5, 2008
  9. Jeff KingMar 5, 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.