git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Christian Couder <christian.couder@gmail.com>
Cc: git@vger.kernel.org, Christian Couder <chriscool@tuxfamily.org>,
	Miriam Rubio <mirucam@gmail.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH v2] bisect: don't use invalid oid as rev when starting
Date: Thu, 24 Sep 2020 12:25:40 -0700	[thread overview]
Message-ID: <xmqqo8lvm0y3.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <xmqqsgb7m2bq.fsf@gitster.c.googlers.com> (Junio C. Hamano's message of "Thu, 24 Sep 2020 11:55:53 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> We may need to audit recent additions of get_oid_committish() calls
> in our codebase.  I suspect there may be other instances of the same
> mistake.
>
> Other than that, the code structure does look more straight-forward
> compared to the previous round.  A fix on this version would involve
> peeling what is in oid down to commit, and you need to handle errors
> during that process, so it may not stay pretty with a fix, though.
> I dunno.

I'll queue it with this band-aid on top for now.

Thanks.

 builtin/bisect--helper.c    | 7 ++++---
 t/t6030-bisect-porcelain.sh | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index a1f97e3f6c..2fcc023a3b 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -474,13 +474,14 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
 		} else if (starts_with(arg, "--") &&
 			 !one_of(arg, "--term-good", "--term-bad", NULL)) {
 			return error(_("unrecognized option: '%s'"), arg);
-		} else if (!get_oid_committish(arg, &oid))
+		} else if (!get_oidf(&oid, "%s^{commit}", arg)) {
 			string_list_append(&revs, oid_to_hex(&oid));
-		else if (has_double_dash)
+		} else if (has_double_dash) {
 			die(_("'%s' does not appear to be a valid "
 			      "revision"), arg);
-		else
+		} else {
 			break;
+		}
 	}
 	pathspec_pos = i;
 
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 94179b6acf..4dbfa63ca1 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -82,7 +82,7 @@ test_expect_success 'bisect fails if given any junk instead of revs' '
 	git bisect bad $HASH4
 '
 
-test_expect_success 'bisect start without -- uses unknown arg as path restriction' '
+test_expect_success 'bisect start without -- takes unknown arg as pathspec' '
 	git bisect reset &&
 	git bisect start foo bar &&
 	grep foo ".git/BISECT_NAMES" &&

  reply	other threads:[~2020-09-24 19:25 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23 17:09 [PATCH] bisect: don't use invalid oid as rev when starting Christian Couder
2020-09-23 17:27 ` Junio C Hamano
2020-09-23 20:37 ` Johannes Schindelin
2020-09-23 21:05   ` Johannes Schindelin
2020-09-23 21:39     ` Junio C Hamano
2020-09-24  6:10       ` Christian Couder
2020-09-24  6:48         ` Junio C Hamano
2020-09-24  7:51         ` Johannes Schindelin
2020-09-24 16:39           ` Junio C Hamano
2020-09-24 18:38             ` Junio C Hamano
2020-09-25  7:13               ` Johannes Schindelin
2020-09-25  7:14                 ` Johannes Schindelin
2020-09-25 16:54                 ` Junio C Hamano
2020-09-24  6:03 ` [PATCH v2] " Christian Couder
2020-09-24  7:49   ` Johannes Schindelin
2020-09-24 11:08     ` Christian Couder
2020-09-24 16:44       ` Junio C Hamano
2020-09-24 18:55   ` Junio C Hamano
2020-09-24 19:25     ` Junio C Hamano [this message]
2020-09-24 19:56     ` Junio C Hamano
2020-09-24 20:53       ` Junio C Hamano
2020-09-25 13:09     ` Christian Couder
2020-09-25 13:01   ` [PATCH v3] " Christian Couder

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqo8lvm0y3.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=chriscool@tuxfamily.org \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mirucam@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).