Subject: Re: Allow git bisect to auto-skip

From: Junio C Hamano <[email-masked]>
Date: Wed, 27 Mar 2024 12:24:43 -0700

Olliver Schinagl <[email-masked]> writes:

> Anyway, want I was thinking of, based a key somewhere in the message
> body (GIT_BISECT_SKIP=1 for example), mark the commit in the list to
> be skipped, as `git bisect skip` would. This so the skipped commit
> actualyl ends up on the list of skipped commits
> (`refs/bisect/skip-*`).

I think it is very unlikely that we'd adopt any hardcoded scheme
that allows only one supported way of marking commits as not to be
tested.  Certainly not the kind that the committer is forced to know
the commit must be skipped during a bisection session before
creating the commit.  So I am not sure how much good it will do to
know that commit_list->item is a commit object on the list, or
calling repo_get_commit_buffer() on it would give the contents of
the commit object.

Knowing that commit_list->item->object.oid is the object name of
such a commit, and calling oid_to_hex() on such an object name
stringifies it, should be sufficient to write a new code that calls
out to a script specified via "git bisect --skip-when=<script>"
using the run_command() API to decide if the commit object should be
skipped, and if you do want GIT_BISECT_SKIP=1 in the log message,
your script given via --skip-when may be a single-liner:

    #!/bin/sh
    # usage: this-script $commit_object_name
    # expected to exit with 0 when the commit should not be tested
    git cat-file commit "$1" | sed -e '1,/^$/d' | grep GIT_BISECT_SKIP=1

Thanks.