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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 5, 2008, 08:48 UTC
Message-ID
<7vwsoho8t4.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080305043319.GA9074@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> I'm not sure it's this easy. We're basically just ignoring the error
> return from get_sha1_with_mode, but do we really want to ignore _all_
> errors? Specifically, should "git log --default foobar" silently produce
> no commits?
Sure.

The thing is, nobody uses "--default" with random crap (i.e. risk of typo running from the command line). It is really about scripted use, and I can guarantee majority of --default argument is HEAD, and in people's custom scripts that are specially tailored for specific workflows, they would use concrete commit object names that their workflow is built around as convention (e.g. "alias.recent = git log --since=1.day --default master").

We could enhance the --default mechanism to say that its argument is optional when it begins with a '?', and change our internal callers to pass the equivalent of "--default ?HEAD", and keep the traditional die() behaviour for non-optional defaults to catch breakages in end-user scripts.

> I think a tighter rule that would accomplish the same thing is "if we
> resolve to a ref that is yet-to-be-born, then ignore." But unfortunately
> that information is lost deep within the bowels of get_sha1_with_mode.

Yes and no. It is in the error path, so you can afford to redo resolving the symref _after_ seeing get_sha1_with_mode() fail.

Previous: Jeff KingNext: Jeff King
Message 7 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.