From: Junio C Hamano <gitster@pobox.com>
To: Kenny Lee Sin Cheong <kenny.lee28@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] Add revision range support on "-" and "@{-1}"
Date: Mon, 16 Mar 2015 23:49:48 -0700 [thread overview]
Message-ID: <xmqq8uewp183.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <xmqqlhiwredj.fsf@gitster.dls.corp.google.com> (Junio C. Hamano's message of "Mon, 16 Mar 2015 11:22:48 -0700")
Junio C Hamano <gitster@pobox.com> writes:
>> @@ -1499,6 +1500,13 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
>> next = head_by_default;
>> if (dotdot == arg)
>> this = head_by_default;
>> + /* Allows -..<rev> and <rev>..- */
>> + if (!strcmp(this, "-")) {
>> + this = prev_rev;
>> + }
>> + if (!strcmp(next, "-")) {
>> + next = prev_rev;
>> + }
>
> The above two hunks are disappointing. "this" and "next" are passed
> to get_sha1_committish() and the point of the [1/2] patch was to
> allow "-" to be just as usable as "@{-1}" anywhere a branch name can
> be used.
>
>> if (this == head_by_default && next == head_by_default &&
>> !symmetric) {
>> /*
>> @@ -2198,7 +2206,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
>> read_from_stdin = 0;
>> for (left = i = 1; i < argc; i++) {
>> const char *arg = argv[i];
>> - if (arg[0] == '-' && arg[1]) {
>> + if (arg[0] == '-' && !strstr(arg, "..")) {
>
> Isn't this way too loose? "--some-opt=I.wish..." would have ".."
> in it, and we would want to leave room to add new options that may
> take arbitrary string as an argument.
>
> I would have expected it would be more like
>
> if (arg[0] == '-' && arg[1] && !starts_with(arg + 1, "..")) {
>
> That is, "anything that begins with '-', if it is to be taken as an
> option, must not begin with '-..'", which I think should be strict
> enough.
I have an updated version to handle the simplest forms of range
notations on 'pu' as d40f108d ("-" and "@{-1}" on various programs,
2015-03-16). I do not think either your !strstr(arg, "..") or my
!starts_with(arg + 1, "..") is correct, if we really wanted to make
"-" a true stand-in for @{-1}, as we would need to stop ourselves
fall into this "This begins with a dash, so it has to be a dashed
option" block when things like these are given:
"-^"
"-~10"
"-^{/^### match next}"
I have a suspicion that it might be a matter of swapping the if
clauses, that is, instead of the current way
if (starts with '-') {
do the option thing;
continue;
}
if (try to see if it is a revision or revision range) {
/* if failed, args must be pathspecs from here on */
check the '--' disambiguation;
add pathspec to prune-data;
} else {
got_rev_arg = 1;
}
which tries "the option thing" first, do something like this:
if (try to see if it is a revision or regvision range) {
/* if failed ... */
if (starts with '-') {
do the option thing;
continue;
}
/* args must be pathspecs from here on */
check the '--' disambiguation;
add pathspec to prune-data;
} else {
got_rev_arg = 1;
}
but I didn't trace the logic myself to see if that would work.
next prev parent reply other threads:[~2015-03-17 6:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-16 15:11 [PATCH/RFC 0/2][GSoC] revision.c: Allow "-" as stand-in for "@{-1}" everywhere a branch is allowed Kenny Lee Sin Cheong
2015-03-16 15:11 ` [PATCH 1/2] "-" and "@{-1}" on various programs Kenny Lee Sin Cheong
2015-03-16 15:11 ` [PATCH 2/2] Add revision range support on "-" and "@{-1}" Kenny Lee Sin Cheong
2015-03-16 18:22 ` Junio C Hamano
2015-03-17 6:49 ` Junio C Hamano [this message]
2015-03-17 21:25 ` Kenny Lee Sin Cheong
2015-03-17 22:16 ` Junio C Hamano
2015-03-24 0:09 ` Kenny Lee Sin Cheong
2015-03-25 22:24 ` Junio C Hamano
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=xmqq8uewp183.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=kenny.lee28@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.