@@ -1484,13 +1484,14 @@ static void write_filename_info(const char *path)
14841484/*
14851485 * Porcelain/Incremental format wants to show a lot of details per
14861486 * commit. Instead of repeating this every line, emit it only once,
1487- * the first time each commit appears in the output.
1487+ * the first time each commit appears in the output (unless the
1488+ * user has specifically asked for us to repeat).
14881489 */
1489- static int emit_one_suspect_detail (struct origin * suspect )
1490+ static int emit_one_suspect_detail (struct origin * suspect , int repeat )
14901491{
14911492 struct commit_info ci ;
14921493
1493- if (suspect -> commit -> object .flags & METAINFO_SHOWN )
1494+ if (! repeat && ( suspect -> commit -> object .flags & METAINFO_SHOWN ) )
14941495 return 0 ;
14951496
14961497 suspect -> commit -> object .flags |= METAINFO_SHOWN ;
@@ -1529,7 +1530,7 @@ static void found_guilty_entry(struct blame_entry *ent)
15291530 printf ("%s %d %d %d\n" ,
15301531 sha1_to_hex (suspect -> commit -> object .sha1 ),
15311532 ent -> s_lno + 1 , ent -> lno + 1 , ent -> num_lines );
1532- emit_one_suspect_detail (suspect );
1533+ emit_one_suspect_detail (suspect , 0 );
15331534 write_filename_info (suspect -> path );
15341535 maybe_flush_or_die (stdout , "stdout" );
15351536 }
@@ -1618,9 +1619,19 @@ static const char *format_time(unsigned long time, const char *tz_str,
16181619#define OUTPUT_SHOW_SCORE 0100
16191620#define OUTPUT_NO_AUTHOR 0200
16201621#define OUTPUT_SHOW_EMAIL 0400
1622+ #define OUTPUT_LINE_PORCELAIN 01000
16211623
1622- static void emit_porcelain (struct scoreboard * sb , struct blame_entry * ent )
1624+ static void emit_porcelain_details (struct origin * suspect , int repeat )
16231625{
1626+ if (emit_one_suspect_detail (suspect , repeat ) ||
1627+ (suspect -> commit -> object .flags & MORE_THAN_ONE_PATH ))
1628+ write_filename_info (suspect -> path );
1629+ }
1630+
1631+ static void emit_porcelain (struct scoreboard * sb , struct blame_entry * ent ,
1632+ int opt )
1633+ {
1634+ int repeat = opt & OUTPUT_LINE_PORCELAIN ;
16241635 int cnt ;
16251636 const char * cp ;
16261637 struct origin * suspect = ent -> suspect ;
@@ -1633,17 +1644,18 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)
16331644 ent -> s_lno + 1 ,
16341645 ent -> lno + 1 ,
16351646 ent -> num_lines );
1636- if (emit_one_suspect_detail (suspect ) ||
1637- (suspect -> commit -> object .flags & MORE_THAN_ONE_PATH ))
1638- write_filename_info (suspect -> path );
1647+ emit_porcelain_details (suspect , repeat );
16391648
16401649 cp = nth_line (sb , ent -> lno );
16411650 for (cnt = 0 ; cnt < ent -> num_lines ; cnt ++ ) {
16421651 char ch ;
1643- if (cnt )
1652+ if (cnt ) {
16441653 printf ("%s %d %d\n" , hex ,
16451654 ent -> s_lno + 1 + cnt ,
16461655 ent -> lno + 1 + cnt );
1656+ if (repeat )
1657+ emit_porcelain_details (suspect , 1 );
1658+ }
16471659 putchar ('\t' );
16481660 do {
16491661 ch = * cp ++ ;
@@ -1756,7 +1768,7 @@ static void output(struct scoreboard *sb, int option)
17561768
17571769 for (ent = sb -> ent ; ent ; ent = ent -> next ) {
17581770 if (option & OUTPUT_PORCELAIN )
1759- emit_porcelain (sb , ent );
1771+ emit_porcelain (sb , ent , option );
17601772 else {
17611773 emit_other (sb , ent , option );
17621774 }
@@ -2300,6 +2312,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
23002312 OPT_BIT ('f' , "show-name" , & output_option , "Show original filename (Default: auto)" , OUTPUT_SHOW_NAME ),
23012313 OPT_BIT ('n' , "show-number" , & output_option , "Show original linenumber (Default: off)" , OUTPUT_SHOW_NUMBER ),
23022314 OPT_BIT ('p' , "porcelain" , & output_option , "Show in a format designed for machine consumption" , OUTPUT_PORCELAIN ),
2315+ OPT_BIT (0 , "line-porcelain" , & output_option , "Show porcelain format with per-line commit information" , OUTPUT_PORCELAIN |OUTPUT_LINE_PORCELAIN ),
23032316 OPT_BIT ('c' , NULL , & output_option , "Use the same output mode as git-annotate (Default: off)" , OUTPUT_ANNOTATE_COMPAT ),
23042317 OPT_BIT ('t' , NULL , & output_option , "Show raw timestamp (Default: off)" , OUTPUT_RAW_TIMESTAMP ),
23052318 OPT_BIT ('l' , NULL , & output_option , "Show long commit SHA1 (Default: off)" , OUTPUT_LONG_OBJECT_NAME ),
0 commit comments