@@ -11,6 +11,7 @@ struct add_i_state {
11
11
struct repository * r ;
12
12
int use_color ;
13
13
char header_color [COLOR_MAXLEN ];
14
+ char help_color [COLOR_MAXLEN ];
14
15
};
15
16
16
17
static void init_color (struct repository * r , struct add_i_state * s ,
@@ -43,6 +44,7 @@ static int init_add_i_state(struct repository *r, struct add_i_state *s)
43
44
s -> use_color = want_color (s -> use_color );
44
45
45
46
init_color (r , s , "header" , s -> header_color , GIT_COLOR_BOLD );
47
+ init_color (r , s , "help" , s -> help_color , GIT_COLOR_BOLD_RED );
46
48
47
49
return 0 ;
48
50
}
@@ -104,6 +106,7 @@ struct list_and_choose_options {
104
106
struct list_options list_opts ;
105
107
106
108
const char * prompt ;
109
+ void (* print_help )(struct add_i_state * s );
107
110
};
108
111
109
112
#define LIST_AND_CHOOSE_ERROR (-1)
@@ -144,6 +147,11 @@ static ssize_t list_and_choose(struct prefix_item **items, size_t nr,
144
147
if (!input .len )
145
148
break ;
146
149
150
+ if (!strcmp (input .buf , "?" )) {
151
+ opts -> print_help (s );
152
+ continue ;
153
+ }
154
+
147
155
p = input .buf ;
148
156
for (;;) {
149
157
size_t sep = strcspn (p , " \t\r\n," );
@@ -431,12 +439,24 @@ struct command_item {
431
439
struct file_list * files , struct list_options * opts );
432
440
};
433
441
442
+ static void command_prompt_help (struct add_i_state * s )
443
+ {
444
+ const char * help_color = s -> help_color ;
445
+ color_fprintf_ln (stdout , help_color , "%s" , _ ("Prompt help:" ));
446
+ color_fprintf_ln (stdout , help_color , "1 - %s" ,
447
+ _ ("select a numbered item" ));
448
+ color_fprintf_ln (stdout , help_color , "foo - %s" ,
449
+ _ ("select item based on unique prefix" ));
450
+ color_fprintf_ln (stdout , help_color , " - %s" ,
451
+ _ ("(empty) select nothing" ));
452
+ }
453
+
434
454
int run_add_i (struct repository * r , const struct pathspec * ps )
435
455
{
436
456
struct add_i_state s = { NULL };
437
457
struct list_and_choose_options main_loop_opts = {
438
458
{ 4 , N_ ("*** Commands ***" ), print_command_item , NULL },
439
- N_ ("What now" )
459
+ N_ ("What now" ), command_prompt_help
440
460
};
441
461
struct command_item
442
462
status = { { "status" }, run_status };
0 commit comments