From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Reece Dunn <msclrhd@googlemail.com>
Subject: Re: [RFC] improve 'bad default revision' message for empty repo
Date: Wed, 5 Mar 2008 04:10:52 -0500 [thread overview]
Message-ID: <20080305091051.GA18377@sigill.intra.peff.net> (raw)
In-Reply-To: <7vwsoho8t4.fsf@gitster.siamese.dyndns.org>
On Wed, Mar 05, 2008 at 12:48:39AM -0800, Junio C Hamano wrote:
> 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").
Well, if you are comfortable, then I have no real objection. I just
wanted to raise the point since I didn't really know how widely and in
what way --default was being used.
> 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.
Sure, that is reasonable. The syntax is a bit ugly. Maybe just set an
ignore_default_errors flag to '1', and then if --default is specified on
the commandline, set it to '0'. The behavior should be identical for all
external scripts, and we can audit the internal uses.
But given your 'master' example above, I think you would actually want
it to be treated in the same way; if master doesn't exist, it is empty.
IOW, it is the "defaultness" which makes one want to ignore errors.
> > 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.
True. Although considering your 'master' example above, it is not just
"symref whose target doesn't exist", but "ref does not exist". In either
case (internal HEAD or explicit --default) I think something like "ref
exists but is corrupted" is something you would expect git to note.
Hrm. Thinking about it a bit more, what should be done with a --default
like "HEAD^^"? It currently works fine, but parsing it down to "HEAD"
requires the magic of get_sha1_with_mode. I think anyone using anything
but an unadorned refname for --default is probably insane, though. Would
it be acceptable to formally disallow it?
-Peff
next prev parent reply other threads:[~2008-03-05 9:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-01 19:40 Some issues working with empty/bare repositories Reece Dunn
2008-03-03 8:10 ` Jeff King
2008-03-04 21:51 ` Reece Dunn
2008-03-05 1:07 ` [RFC] improve 'bad default revision' message for empty repo Jeff King
2008-03-05 2:43 ` Junio C Hamano
2008-03-05 4:33 ` Jeff King
2008-03-05 8:48 ` Junio C Hamano
2008-03-05 9:10 ` Jeff King [this message]
2008-03-05 9:25 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080305091051.GA18377@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=msclrhd@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).