@@ -11,6 +11,7 @@ struct add_i_state {
1111 struct repository * r ;
1212 int use_color ;
1313 char header_color [COLOR_MAXLEN ];
14+ char help_color [COLOR_MAXLEN ];
1415};
1516
1617static 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)
4344 s -> use_color = want_color (s -> use_color );
4445
4546 init_color (r , s , "header" , s -> header_color , GIT_COLOR_BOLD );
47+ init_color (r , s , "help" , s -> help_color , GIT_COLOR_BOLD_RED );
4648
4749 return 0 ;
4850}
@@ -104,6 +106,7 @@ struct list_and_choose_options {
104106 struct list_options list_opts ;
105107
106108 const char * prompt ;
109+ void (* print_help )(struct add_i_state * s );
107110};
108111
109112#define LIST_AND_CHOOSE_ERROR (-1)
@@ -144,6 +147,11 @@ static ssize_t list_and_choose(struct prefix_item **items, size_t nr,
144147 if (!input .len )
145148 break ;
146149
150+ if (!strcmp (input .buf , "?" )) {
151+ opts -> print_help (s );
152+ continue ;
153+ }
154+
147155 p = input .buf ;
148156 for (;;) {
149157 size_t sep = strcspn (p , " \t\r\n," );
@@ -430,12 +438,24 @@ struct command_item {
430438 struct file_list * files , struct list_options * opts );
431439};
432440
441+ static void command_prompt_help (struct add_i_state * s )
442+ {
443+ const char * help_color = s -> help_color ;
444+ color_fprintf_ln (stdout , help_color , "%s" , _ ("Prompt help:" ));
445+ color_fprintf_ln (stdout , help_color , "1 - %s" ,
446+ _ ("select a numbered item" ));
447+ color_fprintf_ln (stdout , help_color , "foo - %s" ,
448+ _ ("select item based on unique prefix" ));
449+ color_fprintf_ln (stdout , help_color , " - %s" ,
450+ _ ("(empty) select nothing" ));
451+ }
452+
433453int run_add_i (struct repository * r , const struct pathspec * ps )
434454{
435455 struct add_i_state s = { NULL };
436456 struct list_and_choose_options main_loop_opts = {
437457 { 4 , N_ ("*** Commands ***" ), print_command_item , NULL },
438- N_ ("What now" )
458+ N_ ("What now" ), command_prompt_help
439459 };
440460 struct command_item
441461 status = { { "status" }, run_status };
0 commit comments