Merge branch 'jk/diff-graph-cleanup'
authorJunio C Hamano <gitster@pobox.com>
Thu, 14 Feb 2013 18:29:59 +0000 (10:29 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Feb 2013 18:29:59 +0000 (10:29 -0800)
Refactors a lot of repetitive code sequence from the graph drawing
code and adds it to the combined diff output.

* jk/diff-graph-cleanup:
  combine-diff.c: teach combined diffs about line prefix
  diff.c: use diff_line_prefix() where applicable
  diff: add diff_line_prefix function
  diff.c: make constant string arguments const
  diff: write prefix to the correct file
  graph: output padding for merge subsequent parents

1  2 
combine-diff.c
diff.c

diff --cc combine-diff.c
index 7f6187f9cd2fc44540cddbcf4bb853231c57397c,35c817bb2c52399c6eaaebb23dc6c3ba05c0ea2b..35d41cd56d2ddb8df416e5e422552ec473294055
@@@ -985,7 -992,12 +992,8 @@@ static void show_patch_diff(struct comb
  static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct rev_info *rev)
  {
        struct diff_options *opt = &rev->diffopt;
 -      int i, offset;
 -      const char *prefix;
 -      int line_termination, inter_name_termination;
 +      int line_termination, inter_name_termination, i;
+       const char *line_prefix = diff_line_prefix(opt);
  
        line_termination = opt->line_termination;
        inter_name_termination = '\t';
        if (rev->loginfo && !rev->no_commit_id)
                show_log(rev);
  
++
        if (opt->output_format & DIFF_FORMAT_RAW) {
 -              offset = strlen(COLONS) - num_parent;
 -              if (offset < 0)
 -                      offset = 0;
 -              prefix = COLONS + offset;
+               printf("%s", line_prefix);
++
 +              /* As many colons as there are parents */
 +              for (i = 0; i < num_parent; i++)
 +                      putchar(':');
  
                /* Show the modes */
 -              for (i = 0; i < num_parent; i++) {
 -                      printf("%s%06o", prefix, p->parent[i].mode);
 -                      prefix = " ";
 -              }
 -              printf("%s%06o", prefix, p->mode);
 +              for (i = 0; i < num_parent; i++)
 +                      printf("%06o ", p->parent[i].mode);
 +              printf("%06o", p->mode);
  
                /* Show sha1's */
                for (i = 0; i < num_parent; i++)
diff --cc diff.c
Simple merge