git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Shawn O. Pearce" <spearce@spearce.org>,
	git@vger.kernel.org,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH 3/3] reject @{-1} not at beginning of object name
Date: Fri, 29 Jan 2010 06:22:19 -0500	[thread overview]
Message-ID: <20100129112219.GC6165@coredump.intra.peff.net> (raw)
In-Reply-To: <7vsk9qknf6.fsf@alter.siamese.dyndns.org>

On Thu, Jan 28, 2010 at 12:02:53PM -0800, Junio C Hamano wrote:

> We might want to use @{-some string that has non digit} for other purposes
> and it may be a safer change to tweak the "do we only have digits" check
> in the post-context to detect and reject only @{-<all digits>}.

I considered that, but I didn't think it was really worth it. If we
later want to make @{-foobar} meaningful, we can loosen the safety check
then.

> But what I am puzzled by the code structure of get_sha1_basic(), which
> looks like this:

You are not the only one who is puzzled. :)

But yes, your analysis of what is there now looks right to me.

> And the place that parses @{-1} and @{u} are different, even though both
> dwim_log() called by the third one and dwim_ref() called by the fourth one
> call substitute_branch_name() and they are perfectly capable of resolving
> @{-1} and @{u} (and even nested stuff like @{-1}@{u}@{u} with your patch).

Ooh, gross. I didn't try @{u}@{u} in my tests, but it should work.

>     Side note.  I am wondering if dwim_log()'s current implementation is
>     even correct in the first place.  When you have two "ambiguous" refs,
>     it appears to me that you will get a warning from dwim_ref(), but if
>     only one of them has a reflog associated with it, dwim_log() won't
>     complain.  Why isn't the function be (1) dwim_ref() to find the ref
>     from abbreviated refname given in str; and then (2) check if the log
>     exists for that ref?

I guess the original rationale was that you might have reflog'd one, so
by asking for "foo@{yesterday}" you are disambiguating as "the one with
a reflog". But that seems kind of useless to me since:

  1. It is somewhat error-prone, as it assumes that from the user's
     perspective, the fact that one ref has a log and the other does not
     is somehow a meaningful disambiguation. Which implies that users
     carefully figure out which refs have reflogs and which do not, and
     I don't think that is true.

  2. For quite a while, we have had logallrefupdates on by default (and
     I don't remember the exact semantics before that, but wasn't it
     enough to simply create a "logs" directory, which meant that you
     either logged everything or nothing?). So I don't even know how you
     would get into a situation where one ref has a log and the other
     does not.

In other words, I totally agree with your statement, and we could
probably just drop the dwim_log code.

> It might be cleaner if the logic went like this instead:

Your logic makes sense to me. I think we could also simply do a
left-to-right parse, eating refs, @{-N}, and @{u} as we go and
converting them into a "real ref". If we get to something else, we stop.
If we have a @{} left, it's a reflog.  Otherwise, it's bogus (I think ^
suffixes and such have already been stripped off at this point).

Interpret_branch_name already does most of the "eating..." part above
(and it needs to remain separate from get_sha1_basic, as things like
"checkout" need to use it directly).

But I didn't really look too hard at it, as:

> But that is a kind of code churn that may not be worth doing.  I dunno.

Yeah, the code was sufficiently nasty and sufficiently core that I
didn't really want to risk breaking it for the sake of cleanup
(especially not during the -rc cycle).

-Peff

  reply	other threads:[~2010-01-29 11:22 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-11 18:49 default behaviour for `gitmerge` (no arguments) Gareth Adams
2010-01-11 19:43 ` Junio C Hamano
2010-01-12 16:23   ` Jeff King
2010-01-12 18:11     ` Junio C Hamano
2010-01-12 18:25       ` Jeff King
2010-01-13  6:57         ` Junio C Hamano
2010-01-13  9:26           ` Johannes Schindelin
2010-01-13  9:47             ` Junio C Hamano
2010-01-13 11:04               ` Johannes Schindelin
2010-01-13 19:48                 ` Junio C Hamano
2010-01-13 22:49                   ` Johannes Schindelin
2010-01-13 23:13                     ` Junio C Hamano
2010-01-20  9:38           ` [PATCH 0/2] @{u} updates Junio C Hamano
2010-01-20  9:38             ` [PATCH 1/2] t1506: more test for @{upstream} syntax Junio C Hamano
2010-01-26 13:07               ` Jeff King
2010-01-26 19:58                 ` Junio C Hamano
2010-01-27 10:24                   ` Jeff King
2010-01-27 18:50                     ` Junio C Hamano
2010-01-28  8:52                       ` Jeff King
2010-01-26 21:32                 ` Junio C Hamano
2010-01-27 11:40                   ` Jeff King
2010-01-27 19:10                     ` Junio C Hamano
2010-01-28  9:44                       ` Jeff King
2010-01-28  9:50                         ` [PATCH 1/3] test combinations of @{} syntax Jeff King
2010-01-28  9:52                         ` [PATCH 2/3] fix parsing of @{-1}@{u} combination Jeff King
2010-01-28  9:56                         ` [PATCH 3/3] reject @{-1} not at beginning of object name Jeff King
2010-01-28 20:02                           ` Junio C Hamano
2010-01-29 11:22                             ` Jeff King [this message]
2010-01-20  9:38             ` [PATCH 2/2] Teach @{upstream} syntax to strbuf_branchanme() Junio C Hamano
2010-01-20 13:08             ` [PATCH 0/2] @{u} updates Johannes Schindelin

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=20100129112219.GC6165@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=spearce@spearce.org \
    /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).