combine-diff: show diffstat with the first parent.
Asking for stat (either with --stat or --patch-with-stat) gives you diffstat for the first parent, even under combine-diff. While the combined patch is useful to highlight the complexity and interaction of the parts touched by all branches when reviewing a merge commit, diffstat is a tool to assess the extent of damage the merge brings in, and showing stat with the first parent is more sensible than clever per-parent diffstat. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Apr 17, 2006 at 22:53 UTC
965f803c323bb72a9dedbbc8f7ba00bbadb6cf58
1 file changed
+19
-5
combine-diff.c
+19
-5
@@ -831,10 +831,11 @@ void show_combined_diff(struct combine_diff_path *p,
831
case DIFF_FORMAT_NAME:
832
show_raw_diff(p, num_parent, rev);
833
return;
834
-
835
- default:
834
case DIFF_FORMAT_PATCH:
835
show_patch_diff(p, num_parent, dense, rev);
836
+ return;
837
+ default:
838
+ return;
839
}
840
}
841
@@ -847,10 +848,13 @@ void diff_tree_combined_merge(const unsigned char *sha1,
848
struct commit_list *parents;
849
struct combine_diff_path *p, *paths = NULL;
850
int num_parent, i, num_paths;
851
+ int do_diffstat;
852
853
+ do_diffstat = (opt->output_format == DIFF_FORMAT_DIFFSTAT ||
854
+ opt->with_stat);
855
diffopts = *opt;
852
- diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
856
diffopts.with_raw = 0;
857
+ diffopts.with_stat = 0;
858
diffopts.recursive = 1;
859
860
/* count parents */
@@ -864,14 +868,24 @@ void diff_tree_combined_merge(const unsigned char *sha1,
868
parents;
869
parents = parents->next, i++) {
870
struct commit *parent = parents->item;
871
+ /* show stat against the first parent even
872
+ * when doing combined diff.
873
+ */
874
+ if (i == 0 && do_diffstat)
875
+ diffopts.output_format = DIFF_FORMAT_DIFFSTAT;
876
+ else
877
+ diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
878
diff_tree_sha1(parent->object.sha1, commit->object.sha1, "",
879
&diffopts);
880
diffcore_std(&diffopts);
881
paths = intersect_paths(paths, i, num_parent);
882
872
- if (diffopts.with_stat && rev->loginfo)
873
- show_log(rev, rev->loginfo, "---\n");
883
+ if (do_diffstat && rev->loginfo)
884
+ show_log(rev, rev->loginfo,
885
+ opt->with_stat ? "---\n" : "\n");
886
diff_flush(&diffopts);
887
+ if (opt->with_stat)
888
+ putchar('\n');
889
}
890
891
/* find out surviving paths */