@@ -525,7 +525,8 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,
525
525
parse_options_start_1 (ctx , argc , argv , prefix , options , flags );
526
526
}
527
527
528
- static void show_negated_gitcomp (const struct option * opts , int nr_noopts )
528
+ static void show_negated_gitcomp (const struct option * opts , int show_all ,
529
+ int nr_noopts )
529
530
{
530
531
int printed_dashdash = 0 ;
531
532
@@ -535,7 +536,8 @@ static void show_negated_gitcomp(const struct option *opts, int nr_noopts)
535
536
536
537
if (!opts -> long_name )
537
538
continue ;
538
- if (opts -> flags & (PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE ))
539
+ if (!show_all &&
540
+ (opts -> flags & (PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE )))
539
541
continue ;
540
542
if (opts -> flags & PARSE_OPT_NONEG )
541
543
continue ;
@@ -572,7 +574,7 @@ static void show_negated_gitcomp(const struct option *opts, int nr_noopts)
572
574
}
573
575
}
574
576
575
- static int show_gitcomp (const struct option * opts )
577
+ static int show_gitcomp (const struct option * opts , int show_all )
576
578
{
577
579
const struct option * original_opts = opts ;
578
580
int nr_noopts = 0 ;
@@ -582,7 +584,8 @@ static int show_gitcomp(const struct option *opts)
582
584
583
585
if (!opts -> long_name )
584
586
continue ;
585
- if (opts -> flags & (PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE ))
587
+ if (!show_all &&
588
+ (opts -> flags & (PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE )))
586
589
continue ;
587
590
588
591
switch (opts -> type ) {
@@ -610,8 +613,8 @@ static int show_gitcomp(const struct option *opts)
610
613
nr_noopts ++ ;
611
614
printf (" --%s%s" , opts -> long_name , suffix );
612
615
}
613
- show_negated_gitcomp (original_opts , -1 );
614
- show_negated_gitcomp (original_opts , nr_noopts );
616
+ show_negated_gitcomp (original_opts , show_all , -1 );
617
+ show_negated_gitcomp (original_opts , show_all , nr_noopts );
615
618
fputc ('\n' , stdout );
616
619
return PARSE_OPT_COMPLETE ;
617
620
}
@@ -723,9 +726,14 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
723
726
if (internal_help && ctx -> total == 1 && !strcmp (arg + 1 , "h" ))
724
727
goto show_usage ;
725
728
726
- /* lone --git-completion-helper is asked by git-completion.bash */
727
- if (ctx -> total == 1 && !strcmp (arg + 1 , "-git-completion-helper" ))
728
- return show_gitcomp (options );
729
+ /*
730
+ * lone --git-completion-helper and --git-completion-helper-all
731
+ * are asked by git-completion.bash
732
+ */
733
+ if (ctx -> total == 1 && !strcmp (arg , "--git-completion-helper" ))
734
+ return show_gitcomp (options , 0 );
735
+ if (ctx -> total == 1 && !strcmp (arg , "--git-completion-helper-all" ))
736
+ return show_gitcomp (options , 1 );
729
737
730
738
if (arg [1 ] != '-' ) {
731
739
ctx -> opt = arg + 1 ;
0 commit comments