@matheusbsbs / matheus-bagliano / commits / 9a1805a872
Fork 0

add a "basic" diff config callback

The diff porcelain uses git_diff_ui_config to set porcelain-ish config options, like automatically turning on color. The plumbing specifically avoids calling this function, since it doesn't want things like automatic color or rename detection. However, some diff options should be set for both plumbing and porcelain. For example, one can still turn on color in git-diff-files using the --color command line option. This means we want the color config from color.diff.* (so that once color is on, we use the user's preferred scheme), but _not_ the color.diff variable. We split the diff config into "ui" and "basic", where "basic" is suitable for use by plumbing (so _most_ things affecting the output should still go into the "ui" part). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jan 4, 2008 at 03:59 UTC 9a1805a8726ee41f25be2e0f2d5f38f1150d38e4
5 files changed +10 -3
builtin-diff-files.c
+1 -1
@@ -21,7 +21,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
21
22 prefix = setup_git_directory_gently(&nongit);
23 init_revisions(&rev, prefix);
24 - git_config(git_default_config); /* no "diff" UI options */
24 + git_config(git_diff_basic_config); /* no "diff" UI options */
25 rev.abbrev = 0;
26
27 if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix))
builtin-diff-index.c
+1 -1
@@ -17,7 +17,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
17 int result;
18
19 init_revisions(&rev, prefix);
20 - git_config(git_default_config); /* no "diff" UI options */
20 + git_config(git_diff_basic_config); /* no "diff" UI options */
21 rev.abbrev = 0;
22
23 argc = setup_revisions(argc, argv, &rev, NULL);
builtin-diff-tree.c
+1 -1
@@ -68,7 +68,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
68 int read_stdin = 0;
69
70 init_revisions(opt, prefix);
71 - git_config(git_default_config); /* no "diff" UI options */
71 + git_config(git_diff_basic_config); /* no "diff" UI options */
72 nr_sha1 = 0;
73 opt->abbrev = 0;
74 opt->diff = 1;
diff.c
+6
@@ -178,6 +178,12 @@ int git_diff_ui_config(const char *var, const char *value)
178 return parse_funcname_pattern(var, ep, value);
179 }
180 }
181 +
182 + return git_diff_basic_config(var, value);
183 +}
184 +
185 +int git_diff_basic_config(const char *var, const char *value)
186 +{
187 if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
188 int slot = parse_diff_color_slot(var, 11);
189 color_parse(value, var, diff_colors[slot]);
diff.h
+1
@@ -172,6 +172,7 @@ extern void diff_unmerge(struct diff_options *,
172 #define DIFF_SETUP_USE_CACHE 2
173 #define DIFF_SETUP_USE_SIZE_CACHE 4
174
175 +extern int git_diff_basic_config(const char *var, const char *value);
176 extern int git_diff_ui_config(const char *var, const char *value);
177 extern void diff_setup(struct diff_options *);
178 extern int diff_opt_parse(struct diff_options *, const char **, int);