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

Re: [PATCH v2] bisect: don't use invalid oid as rev when starting

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 24, 2020, 19:25 UTC
Message-ID
<xmqqo8lvm0y3.fsf@gitster.c.googlers.com>
In-Reply-To
<xmqqsgb7m2bq.fsf@gitster.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
> 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" &&
Previous: Junio C HamanoNext: Junio C Hamano
Message 19 of 23 in “bisect: don't use invalid oid as rev when starting”
  1. bisect: don't use invalid oid as rev when startingChristian Couder, Sep 23, 2020
  2. Junio C HamanoSep 23, 2020
  3. Johannes SchindelinSep 23, 2020
  4. Johannes SchindelinSep 23, 2020
  5. Junio C HamanoSep 23, 2020
  6. Christian CouderSep 24, 2020
  7. Junio C HamanoSep 24, 2020
  8. Johannes SchindelinSep 24, 2020
  9. Junio C HamanoSep 24, 2020
  10. Junio C HamanoSep 24, 2020
  11. Johannes SchindelinSep 25, 2020
  12. Johannes SchindelinSep 25, 2020
  13. Junio C HamanoSep 25, 2020
  14. bisect: don't use invalid oid as rev when startingChristian Couder, Sep 24, 2020
  15. Johannes SchindelinSep 24, 2020
  16. Christian CouderSep 24, 2020
  17. Junio C HamanoSep 24, 2020
  18. Junio C HamanoSep 24, 2020
  19. Junio C HamanoSep 24, 2020
  20. Junio C HamanoSep 24, 2020
  21. Junio C HamanoSep 24, 2020
  22. Christian CouderSep 25, 2020
  23. bisect: don't use invalid oid as rev when startingChristian Couder, Sep 25, 2020

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.