]> git.ipfire.org Git - thirdparty/git.git/commitdiff
bisect--helper: report actual bisect_state() argument on error
authorRené Scharfe <l.s.r@web.de>
Tue, 18 Jan 2022 12:45:57 +0000 (13:45 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 Jan 2022 01:11:22 +0000 (17:11 -0800)
The strvec "args" in bisect_run() is initialized and cleared, but never
added to.  Nevertheless its first member is printed when reporting a
bisect_state() error.  That's not useful, since it's always NULL.

Before d1bbbe45df (bisect--helper: reimplement `bisect_run` shell
function in C, 2021-09-13) the intended new state was reported if it
could not be set.  Reinstate that behavior and remove the unused strvec.

Reported-by: Ramkumar Ramachandra <r@artagnon.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/bisect--helper.c

index 28a2e6a5750b737d18412cde48394b73e9a74c30..1dbc6294ef5b85c6a6c5edd3e1f889a85086a803 100644 (file)
@@ -1093,7 +1093,6 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
 {
        int res = BISECT_OK;
        struct strbuf command = STRBUF_INIT;
-       struct strvec args = STRVEC_INIT;
        struct strvec run_args = STRVEC_INIT;
        const char *new_state;
        int temporary_stdout_fd, saved_stdout;
@@ -1111,8 +1110,6 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
        strvec_push(&run_args, command.buf);
 
        while (1) {
-               strvec_clear(&args);
-
                printf(_("running %s\n"), command.buf);
                res = run_command_v_opt(run_args.v, RUN_USING_SHELL);
 
@@ -1158,13 +1155,12 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
                        res = BISECT_OK;
                } else if (res) {
                        error(_("bisect run failed: 'git bisect--helper --bisect-state"
-                       " %s' exited with error code %d"), args.v[0], res);
+                       " %s' exited with error code %d"), new_state, res);
                } else {
                        continue;
                }
 
                strbuf_release(&command);
-               strvec_clear(&args);
                strvec_clear(&run_args);
                return res;
        }