Subject: [PATCH 5/5] merge: support setting merge.[diff]stat to dynstat

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Mon, 16 Jan 2012 11:48:01 +0700

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 builtin/merge.c |   30 +++++++++++++++++++++++++-----
 1 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index 3a45172..b8280ce 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -46,7 +46,13 @@ static const char * const builtin_merge_usage[] = {
 	NULL
 };
 
-static int show_diffstat = 1, shortlog_len = -1, squash;
+enum show_diffstat {
+	NO_STAT,
+	DIFF_STAT,
+	DYNAMIC_STAT
+};
+
+static int show_diffstat = NO_STAT, shortlog_len = -1, squash;
 static int option_commit = 1, allow_fast_forward = 1;
 static int fast_forward_only, option_edit;
 static int allow_trivial = 1, have_message;
@@ -399,8 +405,15 @@ static void finish(struct commit *head_commit,
 	if (new_head && show_diffstat) {
 		struct diff_options opts;
 		diff_setup(&opts);
-		opts.output_format |=
-			DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
+		switch (show_diffstat) {
+		case DIFF_STAT:
+			opts.output_format |=
+				DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
+			break;
+		case DYNAMIC_STAT:
+			opts.output_format |= DIFF_FORMAT_DYNSTAT;
+			break;
+		}
 		opts.detect_rename = DIFF_DETECT_RENAME;
 		if (diff_setup_done(&opts) < 0)
 			die(_("diff_setup_done failed"));
@@ -554,8 +567,15 @@ static int git_merge_config(const char *k, const char *v, void *cb)
 		return 0;
 	}
 
-	if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat"))
-		show_diffstat = git_config_bool(k, v);
+	if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat")) {
+		int val = git_config_maybe_bool(k, v);
+		if (val != -1)
+			show_diffstat = val ? DIFF_STAT : NO_STAT;
+		else if (!strcasecmp(v, "dynstat"))
+			show_diffstat = DYNAMIC_STAT;
+		else
+			die(_("unrecognized value \"%s\" for %s"), v, k);
+	}
 	else if (!strcmp(k, "pull.twohead"))
 		return git_config_string(&pull_twohead, k, v);
 	else if (!strcmp(k, "pull.octopus"))
-- 
1.7.3.1.256.g2539c.dirty