@@ -37,6 +37,7 @@ struct checkout_opts {
3737 int overwrite_ignore ;
3838 int ignore_skipworktree ;
3939 int ignore_other_worktrees ;
40+ int show_progress ;
4041
4142 const char * new_branch ;
4243 const char * new_branch_force ;
@@ -417,7 +418,7 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o,
417418 opts .reset = 1 ;
418419 opts .merge = 1 ;
419420 opts .fn = oneway_merge ;
420- opts .verbose_update = ! o -> quiet && isatty ( 2 ) ;
421+ opts .verbose_update = o -> show_progress ;
421422 opts .src_index = & the_index ;
422423 opts .dst_index = & the_index ;
423424 parse_tree (tree );
@@ -501,7 +502,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
501502 topts .update = 1 ;
502503 topts .merge = 1 ;
503504 topts .gently = opts -> merge && old -> commit ;
504- topts .verbose_update = ! opts -> quiet && isatty ( 2 ) ;
505+ topts .verbose_update = opts -> show_progress ;
505506 topts .fn = twoway_merge ;
506507 if (opts -> overwrite_ignore ) {
507508 topts .dir = xcalloc (1 , sizeof (* topts .dir ));
@@ -1156,13 +1157,15 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
11561157 N_ ("second guess 'git checkout <no-such-branch>'" )),
11571158 OPT_BOOL (0 , "ignore-other-worktrees" , & opts .ignore_other_worktrees ,
11581159 N_ ("do not check if another worktree is holding the given ref" )),
1160+ OPT_BOOL (0 , "progress" , & opts .show_progress , N_ ("force progress reporting" )),
11591161 OPT_END (),
11601162 };
11611163
11621164 memset (& opts , 0 , sizeof (opts ));
11631165 memset (& new , 0 , sizeof (new ));
11641166 opts .overwrite_ignore = 1 ;
11651167 opts .prefix = prefix ;
1168+ opts .show_progress = -1 ;
11661169
11671170 gitmodules_config ();
11681171 git_config (git_checkout_config , & opts );
@@ -1172,6 +1175,13 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
11721175 argc = parse_options (argc , argv , prefix , options , checkout_usage ,
11731176 PARSE_OPT_KEEP_DASHDASH );
11741177
1178+ if (opts .show_progress < 0 ) {
1179+ if (opts .quiet )
1180+ opts .show_progress = 0 ;
1181+ else
1182+ opts .show_progress = isatty (2 );
1183+ }
1184+
11751185 if (conflict_style ) {
11761186 opts .merge = 1 ; /* implied */
11771187 git_xmerge_config ("merge.conflictstyle" , conflict_style , NULL );
0 commit comments