@@ -3505,22 +3505,27 @@ static int parse_submodule_opt(struct diff_options *options, const char *value)
35053505 return 1 ;
35063506}
35073507
3508+ static void enable_patch_output (int * fmt ) {
3509+ * fmt &= ~DIFF_FORMAT_NO_OUTPUT ;
3510+ * fmt |= DIFF_FORMAT_PATCH ;
3511+ }
3512+
35083513int diff_opt_parse (struct diff_options * options , const char * * av , int ac )
35093514{
35103515 const char * arg = av [0 ];
35113516 const char * optarg ;
35123517 int argcount ;
35133518
35143519 /* Output format options */
3515- if (!strcmp (arg , "-p" ) || !strcmp (arg , "-u" ) || !strcmp (arg , "--patch" ))
3516- options -> output_format |= DIFF_FORMAT_PATCH ;
3517- else if (opt_arg (arg , 'U' , "unified" , & options -> context ))
3518- options -> output_format |= DIFF_FORMAT_PATCH ;
3520+ if (!strcmp (arg , "-p" ) || !strcmp (arg , "-u" ) || !strcmp (arg , "--patch" )
3521+ || opt_arg (arg , 'U' , "unified" , & options -> context ))
3522+ enable_patch_output (& options -> output_format );
35193523 else if (!strcmp (arg , "--raw" ))
35203524 options -> output_format |= DIFF_FORMAT_RAW ;
3521- else if (!strcmp (arg , "--patch-with-raw" ))
3522- options -> output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW ;
3523- else if (!strcmp (arg , "--numstat" ))
3525+ else if (!strcmp (arg , "--patch-with-raw" )) {
3526+ enable_patch_output (& options -> output_format );
3527+ options -> output_format |= DIFF_FORMAT_RAW ;
3528+ } else if (!strcmp (arg , "--numstat" ))
35243529 options -> output_format |= DIFF_FORMAT_NUMSTAT ;
35253530 else if (!strcmp (arg , "--shortstat" ))
35263531 options -> output_format |= DIFF_FORMAT_SHORTSTAT ;
@@ -3542,13 +3547,14 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
35423547 options -> output_format |= DIFF_FORMAT_CHECKDIFF ;
35433548 else if (!strcmp (arg , "--summary" ))
35443549 options -> output_format |= DIFF_FORMAT_SUMMARY ;
3545- else if (!strcmp (arg , "--patch-with-stat" ))
3546- options -> output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT ;
3547- else if (!strcmp (arg , "--name-only" ))
3550+ else if (!strcmp (arg , "--patch-with-stat" )) {
3551+ enable_patch_output (& options -> output_format );
3552+ options -> output_format |= DIFF_FORMAT_DIFFSTAT ;
3553+ } else if (!strcmp (arg , "--name-only" ))
35483554 options -> output_format |= DIFF_FORMAT_NAME ;
35493555 else if (!strcmp (arg , "--name-status" ))
35503556 options -> output_format |= DIFF_FORMAT_NAME_STATUS ;
3551- else if (!strcmp (arg , "-s" ))
3557+ else if (!strcmp (arg , "-s" ) || ! strcmp ( arg , "--no-patch" ) )
35523558 options -> output_format |= DIFF_FORMAT_NO_OUTPUT ;
35533559 else if (!prefixcmp (arg , "--stat" ))
35543560 /* --stat, --stat-width, --stat-name-width, or --stat-count */
@@ -3621,7 +3627,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
36213627
36223628 /* flags options */
36233629 else if (!strcmp (arg , "--binary" )) {
3624- options -> output_format |= DIFF_FORMAT_PATCH ;
3630+ enable_patch_output ( & options -> output_format ) ;
36253631 DIFF_OPT_SET (options , BINARY );
36263632 }
36273633 else if (!strcmp (arg , "--full-index" ))
0 commit comments