@@ -581,11 +581,14 @@ static void emit_rewrite_diff(const char *name_a,
581581 line_prefix , metainfo , a_name .buf , name_a_tab , reset ,
582582 line_prefix , metainfo , b_name .buf , name_b_tab , reset ,
583583 line_prefix , fraginfo );
584- print_line_count (o -> file , lc_a );
584+ if (!o -> irreversible_delete )
585+ print_line_count (o -> file , lc_a );
586+ else
587+ fprintf (o -> file , "?,?" );
585588 fprintf (o -> file , " +" );
586589 print_line_count (o -> file , lc_b );
587590 fprintf (o -> file , " @@%s\n" , reset );
588- if (lc_a )
591+ if (lc_a && ! o -> irreversible_delete )
589592 emit_rewrite_lines (& ecbdata , '-' , data_one , size_one );
590593 if (lc_b )
591594 emit_rewrite_lines (& ecbdata , '+' , data_two , size_two );
@@ -1981,7 +1984,11 @@ static void builtin_diff(const char *name_a,
19811984 }
19821985 }
19831986
1984- if (!DIFF_OPT_TST (o , TEXT ) &&
1987+ if (o -> irreversible_delete && lbl [1 ][0 ] == '/' ) {
1988+ fprintf (o -> file , "%s" , header .buf );
1989+ strbuf_reset (& header );
1990+ goto free_ab_and_return ;
1991+ } else if (!DIFF_OPT_TST (o , TEXT ) &&
19851992 ( (!textconv_one && diff_filespec_is_binary (one )) ||
19861993 (!textconv_two && diff_filespec_is_binary (two )) )) {
19871994 if (fill_mmfile (& mf1 , one ) < 0 || fill_mmfile (& mf2 , two ) < 0 )
@@ -2001,8 +2008,7 @@ static void builtin_diff(const char *name_a,
20012008 fprintf (o -> file , "%sBinary files %s and %s differ\n" ,
20022009 line_prefix , lbl [0 ], lbl [1 ]);
20032010 o -> found_changes = 1 ;
2004- }
2005- else {
2011+ } else {
20062012 /* Crazy xdl interfaces.. */
20072013 const char * diffopts = getenv ("GIT_DIFF_OPTS" );
20082014 xpparam_t xpp ;
@@ -3200,6 +3206,9 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
32003206 return error ("invalid argument to -M: %s" , arg + 2 );
32013207 options -> detect_rename = DIFF_DETECT_RENAME ;
32023208 }
3209+ else if (!strcmp (arg , "-D" ) || !strcmp (arg , "--irreversible-delete" )) {
3210+ options -> irreversible_delete = 1 ;
3211+ }
32033212 else if (!prefixcmp (arg , "-C" ) || !prefixcmp (arg , "--find-copies=" ) ||
32043213 !strcmp (arg , "--find-copies" )) {
32053214 if (options -> detect_rename == DIFF_DETECT_COPY )
0 commit comments