@@ -220,18 +220,17 @@ static int bisect_reset(const char *commit)
220220 }
221221
222222 if (!ref_exists ("BISECT_HEAD" )) {
223- struct strvec argv = STRVEC_INIT ;
223+ struct child_process cmd = CHILD_PROCESS_INIT ;
224224
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 )) {
227228 error (_ ("could not check out original"
228229 " HEAD '%s'. Try 'git bisect"
229230 " reset <commit>'." ), branch .buf );
230231 strbuf_release (& branch );
231- strvec_clear (& argv );
232232 return -1 ;
233233 }
234- strvec_clear (& argv );
235234 }
236235
237236 strbuf_release (& branch );
@@ -765,10 +764,12 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
765764 strbuf_read_file (& start_head , git_path_bisect_start (), 0 );
766765 strbuf_trim (& start_head );
767766 if (!no_checkout ) {
768- const char * argv [] = { "checkout" , start_head .buf ,
769- "--" , NULL };
767+ struct child_process cmd = CHILD_PROCESS_INIT ;
770768
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 )) {
772773 res = error (_ ("checking out '%s' failed."
773774 " Try 'git bisect start "
774775 "<valid-branch>'." ),
@@ -1098,40 +1099,38 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **ar
10981099
10991100static int bisect_visualize (struct bisect_terms * terms , const char * * argv , int argc )
11001101{
1101- struct strvec args = STRVEC_INIT ;
1102- int flags = RUN_COMMAND_NO_STDIN , res = 0 ;
1102+ struct child_process cmd = CHILD_PROCESS_INIT ;
11031103 struct strbuf sb = STRBUF_INIT ;
11041104
11051105 if (bisect_next_check (terms , NULL ) != 0 )
11061106 return BISECT_FAILED ;
11071107
1108+ cmd .no_stdin = 1 ;
11081109 if (!argc ) {
11091110 if ((getenv ("DISPLAY" ) || getenv ("SESSIONNAME" ) || getenv ("MSYSTEM" ) ||
11101111 getenv ("SECURITYSESSIONID" )) && exists_in_PATH ("gitk" )) {
1111- strvec_push (& args , "gitk" );
1112+ strvec_push (& cmd . args , "gitk" );
11121113 } else {
1113- strvec_push (& args , "log" );
1114- flags |= RUN_GIT_CMD ;
1114+ strvec_push (& cmd . args , "log" );
1115+ cmd . git_cmd = 1 ;
11151116 }
11161117 } else {
11171118 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 ;
11201121 } else if (strcmp (argv [0 ], "tig" ) && !starts_with (argv [0 ], "git" ))
1121- flags |= RUN_GIT_CMD ;
1122+ cmd . git_cmd = 1 ;
11221123
1123- strvec_pushv (& args , argv );
1124+ strvec_pushv (& cmd . args , argv );
11241125 }
11251126
1126- strvec_pushl (& args , "--bisect" , "--" , NULL );
1127+ strvec_pushl (& cmd . args , "--bisect" , "--" , NULL );
11271128
11281129 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 );
11301131 strbuf_release (& sb );
11311132
1132- res = run_command_v_opt (args .v , flags );
1133- strvec_clear (& args );
1134- return res ;
1133+ return run_command (& cmd );
11351134}
11361135
11371136static int get_first_good (const char * refname UNUSED ,
@@ -1142,8 +1141,17 @@ static int get_first_good(const char *refname UNUSED,
11421141 return 1 ;
11431142}
11441143
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 )
11471155{
11481156 int rc ;
11491157 enum bisect_error res ;
@@ -1163,8 +1171,7 @@ static int verify_good(const struct bisect_terms *terms,
11631171 if (res != BISECT_OK )
11641172 return -1 ;
11651173
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 );
11681175
11691176 res = bisect_checkout (& current_rev , no_checkout );
11701177 if (res != BISECT_OK )
@@ -1177,7 +1184,6 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
11771184{
11781185 int res = BISECT_OK ;
11791186 struct strbuf command = STRBUF_INIT ;
1180- struct strvec run_args = STRVEC_INIT ;
11811187 const char * new_state ;
11821188 int temporary_stdout_fd , saved_stdout ;
11831189 int is_first_run = 1 ;
@@ -1192,11 +1198,8 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
11921198 return BISECT_FAILED ;
11931199 }
11941200
1195- strvec_push (& run_args , command .buf );
1196-
11971201 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 );
12001203
12011204 /*
12021205 * 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)
12061209 * missing or non-executable script.
12071210 */
12081211 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 );
12101213 is_first_run = 0 ;
12111214 if (rc < 0 ) {
12121215 error (_ ("unable to verify '%s' on good"
@@ -1273,7 +1276,6 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
12731276 }
12741277
12751278 strbuf_release (& command );
1276- strvec_clear (& run_args );
12771279 return res ;
12781280}
12791281
0 commit comments