@@ -220,18 +220,17 @@ static int bisect_reset(const char *commit)
220
220
}
221
221
222
222
if (!ref_exists ("BISECT_HEAD" )) {
223
- struct strvec argv = STRVEC_INIT ;
223
+ struct child_process cmd = CHILD_PROCESS_INIT ;
224
224
225
- strvec_pushl (& argv , "checkout" , branch .buf , "--" , NULL );
226
- if (run_command_v_opt (argv .v , RUN_GIT_CMD )) {
225
+ cmd .git_cmd = 1 ;
226
+ strvec_pushl (& cmd .args , "checkout" , branch .buf , "--" , NULL );
227
+ if (run_command (& cmd )) {
227
228
error (_ ("could not check out original"
228
229
" HEAD '%s'. Try 'git bisect"
229
230
" reset <commit>'." ), branch .buf );
230
231
strbuf_release (& branch );
231
- strvec_clear (& argv );
232
232
return -1 ;
233
233
}
234
- strvec_clear (& argv );
235
234
}
236
235
237
236
strbuf_release (& branch );
@@ -765,10 +764,12 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
765
764
strbuf_read_file (& start_head , git_path_bisect_start (), 0 );
766
765
strbuf_trim (& start_head );
767
766
if (!no_checkout ) {
768
- const char * argv [] = { "checkout" , start_head .buf ,
769
- "--" , NULL };
767
+ struct child_process cmd = CHILD_PROCESS_INIT ;
770
768
771
- if (run_command_v_opt (argv , RUN_GIT_CMD )) {
769
+ cmd .git_cmd = 1 ;
770
+ strvec_pushl (& cmd .args , "checkout" , start_head .buf ,
771
+ "--" , NULL );
772
+ if (run_command (& cmd )) {
772
773
res = error (_ ("checking out '%s' failed."
773
774
" Try 'git bisect start "
774
775
"<valid-branch>'." ),
@@ -1098,40 +1099,38 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **ar
1098
1099
1099
1100
static int bisect_visualize (struct bisect_terms * terms , const char * * argv , int argc )
1100
1101
{
1101
- struct strvec args = STRVEC_INIT ;
1102
- int flags = RUN_COMMAND_NO_STDIN , res = 0 ;
1102
+ struct child_process cmd = CHILD_PROCESS_INIT ;
1103
1103
struct strbuf sb = STRBUF_INIT ;
1104
1104
1105
1105
if (bisect_next_check (terms , NULL ) != 0 )
1106
1106
return BISECT_FAILED ;
1107
1107
1108
+ cmd .no_stdin = 1 ;
1108
1109
if (!argc ) {
1109
1110
if ((getenv ("DISPLAY" ) || getenv ("SESSIONNAME" ) || getenv ("MSYSTEM" ) ||
1110
1111
getenv ("SECURITYSESSIONID" )) && exists_in_PATH ("gitk" )) {
1111
- strvec_push (& args , "gitk" );
1112
+ strvec_push (& cmd . args , "gitk" );
1112
1113
} else {
1113
- strvec_push (& args , "log" );
1114
- flags |= RUN_GIT_CMD ;
1114
+ strvec_push (& cmd . args , "log" );
1115
+ cmd . git_cmd = 1 ;
1115
1116
}
1116
1117
} else {
1117
1118
if (argv [0 ][0 ] == '-' ) {
1118
- strvec_push (& args , "log" );
1119
- flags |= RUN_GIT_CMD ;
1119
+ strvec_push (& cmd . args , "log" );
1120
+ cmd . git_cmd = 1 ;
1120
1121
} else if (strcmp (argv [0 ], "tig" ) && !starts_with (argv [0 ], "git" ))
1121
- flags |= RUN_GIT_CMD ;
1122
+ cmd . git_cmd = 1 ;
1122
1123
1123
- strvec_pushv (& args , argv );
1124
+ strvec_pushv (& cmd . args , argv );
1124
1125
}
1125
1126
1126
- strvec_pushl (& args , "--bisect" , "--" , NULL );
1127
+ strvec_pushl (& cmd . args , "--bisect" , "--" , NULL );
1127
1128
1128
1129
strbuf_read_file (& sb , git_path_bisect_names (), 0 );
1129
- sq_dequote_to_strvec (sb .buf , & args );
1130
+ sq_dequote_to_strvec (sb .buf , & cmd . args );
1130
1131
strbuf_release (& sb );
1131
1132
1132
- res = run_command_v_opt (args .v , flags );
1133
- strvec_clear (& args );
1134
- return res ;
1133
+ return run_command (& cmd );
1135
1134
}
1136
1135
1137
1136
static int get_first_good (const char * refname UNUSED ,
@@ -1142,8 +1141,17 @@ static int get_first_good(const char *refname UNUSED,
1142
1141
return 1 ;
1143
1142
}
1144
1143
1145
- static int verify_good (const struct bisect_terms * terms ,
1146
- const char * * quoted_argv )
1144
+ static int do_bisect_run (const char * command )
1145
+ {
1146
+ struct child_process cmd = CHILD_PROCESS_INIT ;
1147
+
1148
+ printf (_ ("running %s\n" ), command );
1149
+ cmd .use_shell = 1 ;
1150
+ strvec_push (& cmd .args , command );
1151
+ return run_command (& cmd );
1152
+ }
1153
+
1154
+ static int verify_good (const struct bisect_terms * terms , const char * command )
1147
1155
{
1148
1156
int rc ;
1149
1157
enum bisect_error res ;
@@ -1163,8 +1171,7 @@ static int verify_good(const struct bisect_terms *terms,
1163
1171
if (res != BISECT_OK )
1164
1172
return -1 ;
1165
1173
1166
- printf (_ ("running %s\n" ), quoted_argv [0 ]);
1167
- rc = run_command_v_opt (quoted_argv , RUN_USING_SHELL );
1174
+ rc = do_bisect_run (command );
1168
1175
1169
1176
res = bisect_checkout (& current_rev , no_checkout );
1170
1177
if (res != BISECT_OK )
@@ -1177,7 +1184,6 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
1177
1184
{
1178
1185
int res = BISECT_OK ;
1179
1186
struct strbuf command = STRBUF_INIT ;
1180
- struct strvec run_args = STRVEC_INIT ;
1181
1187
const char * new_state ;
1182
1188
int temporary_stdout_fd , saved_stdout ;
1183
1189
int is_first_run = 1 ;
@@ -1192,11 +1198,8 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
1192
1198
return BISECT_FAILED ;
1193
1199
}
1194
1200
1195
- strvec_push (& run_args , command .buf );
1196
-
1197
1201
while (1 ) {
1198
- printf (_ ("running %s\n" ), command .buf );
1199
- res = run_command_v_opt (run_args .v , RUN_USING_SHELL );
1202
+ res = do_bisect_run (command .buf );
1200
1203
1201
1204
/*
1202
1205
* Exit code 126 and 127 can either come from the shell
@@ -1206,7 +1209,7 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
1206
1209
* missing or non-executable script.
1207
1210
*/
1208
1211
if (is_first_run && (res == 126 || res == 127 )) {
1209
- int rc = verify_good (terms , run_args . v );
1212
+ int rc = verify_good (terms , command . buf );
1210
1213
is_first_run = 0 ;
1211
1214
if (rc < 0 ) {
1212
1215
error (_ ("unable to verify '%s' on good"
@@ -1273,7 +1276,6 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
1273
1276
}
1274
1277
1275
1278
strbuf_release (& command );
1276
- strvec_clear (& run_args );
1277
1279
return res ;
1278
1280
}
1279
1281
0 commit comments