@@ -5022,6 +5022,18 @@ static int diff_opt_line_prefix(const struct option *opt,
50225022 return 0 ;
50235023}
50245024
5025+ static int diff_opt_no_prefix (const struct option * opt ,
5026+ const char * optarg , int unset )
5027+ {
5028+ struct diff_options * options = opt -> value ;
5029+
5030+ BUG_ON_OPT_NEG (unset );
5031+ BUG_ON_OPT_ARG (optarg );
5032+ options -> a_prefix = "" ;
5033+ options -> b_prefix = "" ;
5034+ return 0 ;
5035+ }
5036+
50255037static enum parse_opt_result diff_opt_output (struct parse_opt_ctx_t * ctx ,
50265038 const struct option * opt ,
50275039 const char * arg , int unset )
@@ -5276,6 +5288,9 @@ static void prep_parse_options(struct diff_options *options)
52765288 OPT_CALLBACK_F (0 , "line-prefix" , options , N_ ("<prefix>" ),
52775289 N_ ("prepend an additional prefix to every line of output" ),
52785290 PARSE_OPT_NONEG , diff_opt_line_prefix ),
5291+ OPT_CALLBACK_F (0 , "no-prefix" , options , NULL ,
5292+ N_ ("do not show any source or destination prefix" ),
5293+ PARSE_OPT_NONEG | PARSE_OPT_NOARG , diff_opt_no_prefix ),
52795294 OPT_CALLBACK_F (0 , "output-indicator-new" ,
52805295 & options -> output_indicators [OUTPUT_INDICATOR_NEW ],
52815296 N_ ("<char>" ),
@@ -5468,8 +5483,6 @@ int diff_opt_parse(struct diff_options *options,
54685483 }
54695484
54705485 /* misc options */
5471- else if (!strcmp (arg , "--no-prefix" ))
5472- options -> a_prefix = options -> b_prefix = "" ;
54735486 else if (opt_arg (arg , '\0' , "inter-hunk-context" ,
54745487 & options -> interhunkcontext ))
54755488 ;
0 commit comments