@matheusbsbs / matheus-bagliano / commits / 83ad63cfeb
Fork 0

diff: do not use configuration magic at the core-level

The Porcelainish has become so much usable as the UI that there is not much reason people should be using the core programs by hand anymore. At this point we are better off making the behaviour of the core programs predictable by keeping them unaffected by the configuration variables. Otherwise they will become very hard to use as reliable building blocks. For example, "git-commit -a" internally uses git-diff-files to figure out the set of paths that need to be updated in the index, and we should never allow diff.renames that happens to be in the configuration to interfere (or slow down the process). The UI level configuration such as showing renamed diff and coloring are still honored by the Porcelainish ("git log" family and "git diff"), but not by the core anymore. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jul 8, 2006 at 01:05 UTC 83ad63cfebdf652ff7c7b255d700d8b12c756913
8 files changed +17 -11
builtin-diff-files.c
+1 -1
@@ -18,7 +18,7 @@ int cmd_diff_files(int argc, const char **argv, char **envp)
18 struct rev_info rev;
19 int silent = 0;
20
21 - git_config(git_diff_config);
21 + git_config(git_default_config); /* no "diff" UI options */
22 init_revisions(&rev);
23 rev.abbrev = 0;
24
builtin-diff-index.c
+1 -1
@@ -15,7 +15,7 @@ int cmd_diff_index(int argc, const char **argv, char **envp)
15 int cached = 0;
16 int i;
17
18 - git_config(git_diff_config);
18 + git_config(git_default_config); /* no "diff" UI options */
19 init_revisions(&rev);
20 rev.abbrev = 0;
21
builtin-diff-stages.c
+1 -1
@@ -61,7 +61,7 @@ int cmd_diff_stages(int ac, const char **av, char **envp)
61 const char *prefix = setup_git_directory();
62 const char **pathspec = NULL;
63
64 - git_config(git_diff_config);
64 + git_config(git_default_config); /* no "diff" UI options */
65 read_cache();
66 diff_setup(&diff_options);
67 while (1 < ac && av[1][0] == '-') {
builtin-diff-tree.c
+1 -1
@@ -67,7 +67,7 @@ int cmd_diff_tree(int argc, const char **argv, char **envp)
67 static struct rev_info *opt = &log_tree_opt;
68 int read_stdin = 0;
69
70 - git_config(git_diff_config);
70 + git_config(git_default_config); /* no "diff" UI options */
71 nr_sha1 = 0;
72 init_revisions(opt);
73 opt->abbrev = 0;
builtin-diff.c
+1 -1
@@ -250,7 +250,7 @@ int cmd_diff(int argc, const char **argv, char **envp)
250 * Other cases are errors.
251 */
252
253 - git_config(git_diff_config);
253 + git_config(git_diff_ui_config);
254 init_revisions(&rev);
255
256 argc = setup_revisions(argc, argv, &rev, NULL);
builtin-log.c
+4 -4
@@ -47,7 +47,7 @@ int cmd_whatchanged(int argc, const char **argv, char **envp)
47 {
48 struct rev_info rev;
49
50 - git_config(git_diff_config);
50 + git_config(git_diff_ui_config);
51 init_revisions(&rev);
52 rev.diff = 1;
53 rev.diffopt.recursive = 1;
@@ -62,7 +62,7 @@ int cmd_show(int argc, const char **argv, char **envp)
62 {
63 struct rev_info rev;
64
65 - git_config(git_diff_config);
65 + git_config(git_diff_ui_config);
66 init_revisions(&rev);
67 rev.diff = 1;
68 rev.diffopt.recursive = 1;
@@ -79,7 +79,7 @@ int cmd_log(int argc, const char **argv, char **envp)
79 {
80 struct rev_info rev;
81
82 - git_config(git_diff_config);
82 + git_config(git_diff_ui_config);
83 init_revisions(&rev);
84 rev.always_show_header = 1;
85 cmd_log_init(argc, argv, envp, &rev);
@@ -105,7 +105,7 @@ static int git_format_config(const char *var, const char *value)
105 strcat(extra_headers, value);
106 return 0;
107 }
108 - return git_diff_config(var, value);
108 + return git_diff_ui_config(var, value);
109 }
110
111
diff.c
+7 -1
@@ -102,7 +102,13 @@ static const char *parse_diff_color_value(const char *value, const char *var)
102 die("bad config value '%s' for variable '%s'", value, var);
103 }
104
105 -int git_diff_config(const char *var, const char *value)
105 +/*
106 + * These are to give UI layer defaults.
107 + * The core-level commands such as git-diff-files should
108 + * never be affected by the setting of diff.renames
109 + * the user happens to have in the configuration file.
110 + */
111 +int git_diff_ui_config(const char *var, const char *value)
112 {
113 if (!strcmp(var, "diff.renamelimit")) {
114 diff_rename_limit_default = git_config_int(var, value);
diff.h
+1 -1
@@ -123,7 +123,7 @@ extern int diff_scoreopt_parse(const char *opt);
123 #define DIFF_SETUP_USE_CACHE 2
124 #define DIFF_SETUP_USE_SIZE_CACHE 4
125
126 -extern int git_diff_config(const char *var, const char *value);
126 +extern int git_diff_ui_config(const char *var, const char *value);
127 extern void diff_setup(struct diff_options *);
128 extern int diff_opt_parse(struct diff_options *, const char **, int);
129 extern int diff_setup_done(struct diff_options *);