Skip to content

Commit 9a1805a

Browse files
peffgitster
authored andcommitted
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>
1 parent 061d6b9 commit 9a1805a

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

builtin-diff-files.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
2121

2222
prefix = setup_git_directory_gently(&nongit);
2323
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 */
2525
rev.abbrev = 0;
2626

2727
if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix))

builtin-diff-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
1717
int result;
1818

1919
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 */
2121
rev.abbrev = 0;
2222

2323
argc = setup_revisions(argc, argv, &rev, NULL);

builtin-diff-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
6868
int read_stdin = 0;
6969

7070
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 */
7272
nr_sha1 = 0;
7373
opt->abbrev = 0;
7474
opt->diff = 1;

diff.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ int git_diff_ui_config(const char *var, const char *value)
178178
return parse_funcname_pattern(var, ep, value);
179179
}
180180
}
181+
182+
return git_diff_basic_config(var, value);
183+
}
184+
185+
int git_diff_basic_config(const char *var, const char *value)
186+
{
181187
if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
182188
int slot = parse_diff_color_slot(var, 11);
183189
color_parse(value, var, diff_colors[slot]);

diff.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ extern void diff_unmerge(struct diff_options *,
172172
#define DIFF_SETUP_USE_CACHE 2
173173
#define DIFF_SETUP_USE_SIZE_CACHE 4
174174

175+
extern int git_diff_basic_config(const char *var, const char *value);
175176
extern int git_diff_ui_config(const char *var, const char *value);
176177
extern void diff_setup(struct diff_options *);
177178
extern int diff_opt_parse(struct diff_options *, const char **, int);

0 commit comments

Comments
 (0)