Skip to content

Commit f37d0bd

Browse files
sgnttaylorr
authored andcommitted
bisect: fix output regressions in v2.30.0
When d1bbbe4 (bisect--helper: reimplement `bisect_run` shell function in C, 2021-09-13) reimplemented parts of "git bisect run" in C it changed the output we emitted so that: - The "running ..." line was now quoted - We lost the \n after our output - We started saying "bisect found ..." instead of "bisect run success" Arguably some of this is better now, but as d1bbbe4 did not advocate for changing the output, let's revert this for now. It'll be easy to change it back if that's what we'd prefer. This does not change the one remaining use of "command.buf" to emit the quoted argument, as that's new in d1bbbe4. Some of these cases were not tested for in the tests added in the preceding commit, I didn't have time to fleshen those out, but a look at f1de981 will show that the other output being adjusted here is now equivalent to what it was before d1bbbe4. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Đoàn Trần Công Danh <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent bdd2aa8 commit f37d0bd

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

builtin/bisect--helper.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,17 +1141,17 @@ static int get_first_good(const char *refname UNUSED,
11411141
return 1;
11421142
}
11431143

1144-
static int do_bisect_run(const char *command)
1144+
static int do_bisect_run(const char *command, const char *unquoted_cmd)
11451145
{
11461146
struct child_process cmd = CHILD_PROCESS_INIT;
11471147

1148-
printf(_("running %s\n"), command);
1148+
printf(_("running %s\n"), unquoted_cmd);
11491149
cmd.use_shell = 1;
11501150
strvec_push(&cmd.args, command);
11511151
return run_command(&cmd);
11521152
}
11531153

1154-
static int verify_good(const struct bisect_terms *terms, const char *command)
1154+
static int verify_good(const struct bisect_terms *terms, const char *command, const char *unquoted_cmd)
11551155
{
11561156
int rc;
11571157
enum bisect_error res;
@@ -1171,7 +1171,7 @@ static int verify_good(const struct bisect_terms *terms, const char *command)
11711171
if (res != BISECT_OK)
11721172
return -1;
11731173

1174-
rc = do_bisect_run(command);
1174+
rc = do_bisect_run(command, unquoted_cmd);
11751175

11761176
res = bisect_checkout(&current_rev, no_checkout);
11771177
if (res != BISECT_OK)
@@ -1184,6 +1184,7 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
11841184
{
11851185
int res = BISECT_OK;
11861186
struct strbuf command = STRBUF_INIT;
1187+
struct strbuf unquoted = STRBUF_INIT;
11871188
const char *new_state;
11881189
int temporary_stdout_fd, saved_stdout;
11891190
int is_first_run = 1;
@@ -1197,8 +1198,9 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
11971198
}
11981199

11991200
sq_quote_argv(&command, argv);
1201+
strbuf_join_argv(&unquoted, argc, argv,' ');
12001202
while (1) {
1201-
res = do_bisect_run(command.buf);
1203+
res = do_bisect_run(command.buf, unquoted.buf);
12021204

12031205
/*
12041206
* Exit code 126 and 127 can either come from the shell
@@ -1208,11 +1210,11 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
12081210
* missing or non-executable script.
12091211
*/
12101212
if (is_first_run && (res == 126 || res == 127)) {
1211-
int rc = verify_good(terms, command.buf);
1213+
int rc = verify_good(terms, command.buf, unquoted.buf);
12121214
is_first_run = 0;
12131215
if (rc < 0) {
12141216
error(_("unable to verify '%s' on good"
1215-
" revision"), command.buf);
1217+
" revision"), unquoted.buf);
12161218
res = BISECT_FAILED;
12171219
break;
12181220
}
@@ -1226,7 +1228,7 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
12261228

12271229
if (res < 0 || 128 <= res) {
12281230
error(_("bisect run failed: exit code %d from"
1229-
" '%s' is < 0 or >= 128"), res, command.buf);
1231+
" '%s' is < 0 or >= 128"), res, unquoted.buf);
12301232
break;
12311233
}
12321234

@@ -1260,20 +1262,21 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
12601262
if (res == BISECT_ONLY_SKIPPED_LEFT)
12611263
error(_("bisect run cannot continue any more"));
12621264
else if (res == BISECT_INTERNAL_SUCCESS_MERGE_BASE) {
1263-
printf(_("bisect run success"));
1265+
puts(_("bisect run success"));
12641266
res = BISECT_OK;
12651267
} else if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) {
1266-
printf(_("bisect found first bad commit"));
1268+
puts(_("bisect run success"));
12671269
res = BISECT_OK;
12681270
} else if (res) {
1269-
error(_("bisect run failed: 'git bisect--helper --bisect-state"
1270-
" %s' exited with error code %d"), new_state, res);
1271+
error(_("bisect run failed: 'bisect-state %s'"
1272+
" exited with error code %d"), new_state, res);
12711273
} else {
12721274
continue;
12731275
}
12741276
break;
12751277
}
12761278

1279+
strbuf_release(&unquoted);
12771280
strbuf_release(&command);
12781281
return res;
12791282
}

t/t6030-bisect-porcelain.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ test_bisect_run_args () {
285285
test_cmp expect.args actual.args
286286
}
287287

288-
test_expect_failure 'git bisect run: args, stdout and stderr with no arguments' "
288+
test_expect_success 'git bisect run: args, stdout and stderr with no arguments' "
289289
test_bisect_run_args <<-'EOF_ARGS' 6<<-EOF_OUT 7<<-'EOF_ERR'
290290
EOF_ARGS
291291
running ./run.sh
@@ -295,7 +295,7 @@ test_expect_failure 'git bisect run: args, stdout and stderr with no arguments'
295295
EOF_ERR
296296
"
297297

298-
test_expect_failure 'git bisect run: args, stdout and stderr: "--" argument' "
298+
test_expect_success 'git bisect run: args, stdout and stderr: "--" argument' "
299299
test_bisect_run_args -- <<-'EOF_ARGS' 6<<-EOF_OUT 7<<-'EOF_ERR'
300300
<-->
301301
EOF_ARGS
@@ -306,7 +306,7 @@ test_expect_failure 'git bisect run: args, stdout and stderr: "--" argument' "
306306
EOF_ERR
307307
"
308308

309-
test_expect_failure 'git bisect run: args, stdout and stderr: "--log foo --no-log bar" arguments' "
309+
test_expect_success 'git bisect run: args, stdout and stderr: "--log foo --no-log bar" arguments' "
310310
test_bisect_run_args --log foo --no-log bar <<-'EOF_ARGS' 6<<-EOF_OUT 7<<-'EOF_ERR'
311311
<--log>
312312
<foo>
@@ -320,7 +320,7 @@ test_expect_failure 'git bisect run: args, stdout and stderr: "--log foo --no-lo
320320
EOF_ERR
321321
"
322322

323-
test_expect_failure 'git bisect run: args, stdout and stderr: "--bisect-start" argument' "
323+
test_expect_success 'git bisect run: args, stdout and stderr: "--bisect-start" argument' "
324324
test_bisect_run_args --bisect-start <<-'EOF_ARGS' 6<<-EOF_OUT 7<<-'EOF_ERR'
325325
<--bisect-start>
326326
EOF_ARGS

0 commit comments

Comments
 (0)