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

Re: [PATCH v6 06/13] bisect--helper: reimplement `bisect_next` and `bisect_auto_next` shell functions in C

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 29, 2020, 19:31 UTC
Message-ID
<xmqq8sdxi70a.fsf@gitster.c.googlers.com>
In-Reply-To
<20200828124617.60618-7-mirucam@gmail.com>
Miriam Rubio <mirucam@gmail.com> writes:
Show 17 quoted lines
> diff --git a/bisect.c b/bisect.c
> index c6aba2b9f2..f0fca5c6f3 100644
> --- a/bisect.c
> +++ b/bisect.c
> @@ -988,6 +988,12 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
>   * the bisection process finished successfully.
>   * In this case the calling function or command should not turn a
>   * BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND return code into an error or a non zero exit code.
> + *
> + * Checking BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND
> + * in bisect_helper::bisect_next() and only transforming it to 0 at
> + * the end of bisect_helper::cmd_bisect__helper() helps bypassing
> + * all the code related to finding a commit to test.
> + *
>   * If no_checkout is non-zero, the bisection process does not
>   * checkout the trial commit but instead simply updates BISECT_HEAD.
>   */

Not a problem introduced by this step, but the above description on no_checkout describes a parameter that no longer exists.

The comments before a function is to guide the developers how to call the function correctly, so it should have been removed, moved to where no_checkout is used in the function, or moved to where BISECT_HEAD ref gets created, as necessary, but by mistake be5fe200 (cmd_bisect__helper: defer parsing no-checkout flag, 2020-08-07), forgot to do any of the three.

Show 24 quoted lines
> +static enum bisect_error bisect_next(struct bisect_terms *terms, const char *prefix)
> +{
> +	int no_checkout;
> +	enum bisect_error res;
> +
> +	bisect_autostart(terms);
> +	if (bisect_next_check(terms, terms->term_good))
> +		return BISECT_FAILED;
> +
> +	no_checkout = ref_exists("BISECT_HEAD");
> +
> +	/* Perform all bisection computation */
> +	res = bisect_next_all(the_repository, prefix);
> +
> +	if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) {
> +		res = bisect_successful(terms);
> +		return res ? res : BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND;
> +	} else if (res == BISECT_ONLY_SKIPPED_LEFT) {
> +		res = bisect_skipped_commits(terms);
> +		return res ? res : BISECT_ONLY_SKIPPED_LEFT;
> +	}
> +	return res;
> +}
> +

The no_checkout local variable is assigned but never used. It is understandable if a variable that used to be used becomes unused when some part (i.e. the part that used to use the variable) of a function is factored out, but it is rather unusual how a brand new function has such an unused code and stay to be that way throughout a topic. Makes a reviewer suspect that there may be a code missing, that has to use the variable to decide to do things differently, in this function. It seems to break -Werror builds.

Thanks.
Previous: Miriam RubioNext: Miriam R.
Message 8 of 18 in “Finish converting git bisect to C part 2”
  1. 00/13 Finish converting git bisect to C part 2Miriam Rubio, Aug 28, 2020
  2. 01/13 bisect--helper: BUG() in cmd_*() on invalid subcommandMiriam Rubio, Aug 28, 2020
  3. 02/13 bisect--helper: use '-res' in 'cmd_bisect__helper' returnMiriam Rubio, Aug 28, 2020
  4. 03/13 bisect--helper: introduce new `write_in_file()` functionMiriam Rubio, Aug 28, 2020
  5. 05/13 bisect: call 'clear_commit_marks_all()' in 'bisect_next_all()'Miriam Rubio, Aug 28, 2020
  6. 04/13 bisect--helper: reimplement `bisect_autostart` shell function in CMiriam Rubio, Aug 28, 2020
  7. 06/13 bisect--helper: reimplement `bisect_next` and `bisect_auto_next` shell functions in CMiriam Rubio, Aug 28, 2020
  8. Junio C HamanoAug 29, 2020
  9. Miriam R.Aug 31, 2020
  10. Junio C HamanoAug 31, 2020
  11. 07/13 bisect--helper: finish porting `bisect_start()` to CMiriam Rubio, Aug 28, 2020
  12. 08/13 bisect--helper: retire `--bisect-clean-state` subcommandMiriam Rubio, Aug 28, 2020
  13. 09/13 bisect--helper: retire `--next-all` subcommandMiriam Rubio, Aug 28, 2020
  14. 10/13 bisect--helper: reimplement `bisect_state` & `bisect_head` shell functions in CMiriam Rubio, Aug 28, 2020
  15. 11/13 bisect--helper: retire `--check-expected-revs` subcommandMiriam Rubio, Aug 28, 2020
  16. 12/13 bisect--helper: retire `--write-terms` subcommandMiriam Rubio, Aug 28, 2020
  17. 13/13 bisect--helper: retire `--bisect-autostart` subcommandMiriam Rubio, Aug 28, 2020
  18. Junio C HamanoAug 29, 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.