@@ -97,13 +97,15 @@ static void wt_status_print_dirty_header(struct wt_status *s,
97
97
color_fprintf_ln (s -> fp , c , "#" );
98
98
}
99
99
100
- static void wt_status_print_untracked_header (struct wt_status * s )
100
+ static void wt_status_print_other_header (struct wt_status * s ,
101
+ const char * what ,
102
+ const char * how )
101
103
{
102
104
const char * c = color (WT_STATUS_HEADER , s );
103
- color_fprintf_ln (s -> fp , c , "# Untracked files:" );
105
+ color_fprintf_ln (s -> fp , c , "# %s files:" , what );
104
106
if (!advice_status_hints )
105
107
return ;
106
- color_fprintf_ln (s -> fp , c , "# (use \"git add <file>...\" to include in what will be committed)" );
108
+ color_fprintf_ln (s -> fp , c , "# (use \"git %s <file>...\" to include in what will be committed)" , how );
107
109
color_fprintf_ln (s -> fp , c , "#" );
108
110
}
109
111
@@ -541,18 +543,22 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
541
543
run_command (& sm_summary );
542
544
}
543
545
544
- static void wt_status_print_untracked (struct wt_status * s )
546
+ static void wt_status_print_other (struct wt_status * s ,
547
+ struct string_list * l ,
548
+ const char * what ,
549
+ const char * how )
545
550
{
546
551
int i ;
547
552
struct strbuf buf = STRBUF_INIT ;
548
553
549
554
if (!s -> untracked .nr )
550
555
return ;
551
556
552
- wt_status_print_untracked_header (s );
553
- for (i = 0 ; i < s -> untracked .nr ; i ++ ) {
557
+ wt_status_print_other_header (s , what , how );
558
+
559
+ for (i = 0 ; i < l -> nr ; i ++ ) {
554
560
struct string_list_item * it ;
555
- it = & (s -> untracked . items [i ]);
561
+ it = & (l -> items [i ]);
556
562
color_fprintf (s -> fp , color (WT_STATUS_HEADER , s ), "#\t" );
557
563
color_fprintf_ln (s -> fp , color (WT_STATUS_UNTRACKED , s ), "%s" ,
558
564
quote_path (it -> string , strlen (it -> string ),
@@ -641,7 +647,7 @@ void wt_status_print(struct wt_status *s)
641
647
wt_status_print_submodule_summary (s , 1 ); /* unstaged */
642
648
}
643
649
if (s -> show_untracked_files )
644
- wt_status_print_untracked ( s );
650
+ wt_status_print_other ( s , & s -> untracked , "Untracked" , "add" );
645
651
else if (s -> commitable )
646
652
fprintf (s -> fp , "# Untracked files not listed (use -u option to show untracked files)\n" );
647
653
0 commit comments