wt-status: load diff ui config
When "git status -v" shows a diff, we did not respect the user's usual diff preferences at all. Loading just git_diff_basic_config would give us things like rename limits and diff drivers. But it makes even more sense to load git_diff_ui_config, which gives us colorization if the user has requested it. Note that we need to take special care to cancel colorization when writing to the commit template file, as described in the code comments. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Oct 26, 2008 at 00:49 UTC
4f672ad6c77bfe73cc5dd4b240fd42303d101d2a
2 files changed
+17
-1
t/t7502-commit.sh
+8
@@ -89,6 +89,14 @@ test_expect_success 'verbose' '
89
90
'
91
92
+test_expect_success 'verbose respects diff config' '
93
+
94
+ git config color.diff always &&
95
+ git status -v >actual &&
96
+ grep "\[1mdiff --git" actual &&
97
+ git config --unset color.diff
98
+'
99
+
100
test_expect_success 'cleanup commit messages (verbatim,-t)' '
101
102
echo >>negative &&
wt-status.c
+9
-1
@@ -303,6 +303,14 @@ static void wt_status_print_verbose(struct wt_status *s)
303
rev.diffopt.detect_rename = 1;
304
rev.diffopt.file = s->fp;
305
rev.diffopt.close_file = 0;
306
+ /*
307
+ * If we're not going to stdout, then we definitely don't
308
+ * want color, since we are going to the commit message
309
+ * file (and even the "auto" setting won't work, since it
310
+ * will have checked isatty on stdout).
311
+ */
312
+ if (s->fp != stdout)
313
+ DIFF_OPT_CLR(&rev.diffopt, COLOR_DIFF);
314
run_diff_index(&rev, 1);
315
}
316
@@ -422,5 +430,5 @@ int git_status_config(const char *k, const char *v, void *cb)
430
return error("Invalid untracked files mode '%s'", v);
431
return 0;
432
}
425
- return git_color_default_config(k, v, cb);
433
+ return git_diff_ui_config(k, v, cb);
434
}