@matheusbsbs / matheus-bagliano / commits / ef1d9c5aa4
Fork 0

log and diff family: honor config even from subdirectories

There currently is an unfortunate circular dependency between what init_revisions (the command line revision specification parser) does and setting up the log and diff options. The function uses setup_git_directory() to find the root of the project relative to the current directory and calls diff_setup() to prepare diff generation. However, some of the things that diff_setup() does needs to depend on the configuration variable, which needs to be read after setup_git_directory() is called. This patch is a low impact workaround. It first lets init_revisions() to run and do its thing, then uses git_config() and diff_setup() after it returns, so that configuration variables that affects the diff operation can be used from subdirectories. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jul 27, 2006 at 22:55 UTC ef1d9c5aa4c8fd57b2a8043c0cd9fea1c507db6a
5 files changed +11 -7
builtin-diff-files.c
+1 -1
@@ -18,8 +18,8 @@ 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_default_config); /* no "diff" UI options */
21 init_revisions(&rev);
22 + git_config(git_default_config); /* no "diff" UI options */
23 rev.abbrev = 0;
24
25 argc = setup_revisions(argc, argv, &rev, NULL);
builtin-diff-index.c
+1 -1
@@ -15,8 +15,8 @@ int cmd_diff_index(int argc, const char **argv, char **envp)
15 int cached = 0;
16 int i;
17
18 - git_config(git_default_config); /* no "diff" UI options */
18 init_revisions(&rev);
19 + git_config(git_default_config); /* no "diff" UI options */
20 rev.abbrev = 0;
21
22 argc = setup_revisions(argc, argv, &rev, NULL);
builtin-diff-tree.c
+1 -1
@@ -67,9 +67,9 @@ 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 + init_revisions(opt);
71 git_config(git_default_config); /* no "diff" UI options */
72 nr_sha1 = 0;
72 - init_revisions(opt);
73 opt->abbrev = 0;
74 opt->diff = 1;
75 argc = setup_revisions(argc, argv, opt, NULL);
builtin-diff.c
+2 -1
@@ -250,8 +250,9 @@ int cmd_diff(int argc, const char **argv, char **envp)
250 * Other cases are errors.
251 */
252
253 - git_config(git_diff_ui_config);
253 init_revisions(&rev);
254 + git_config(git_diff_ui_config);
255 + diff_setup(&rev.diffopt);
256
257 argc = setup_revisions(argc, argv, &rev, NULL);
258 if (!rev.diffopt.output_format) {
builtin-log.c
+6 -3
@@ -49,8 +49,9 @@ int cmd_whatchanged(int argc, const char **argv, char **envp)
49 {
50 struct rev_info rev;
51
52 - git_config(git_diff_ui_config);
52 init_revisions(&rev);
53 + git_config(git_diff_ui_config);
54 + diff_setup(&rev.diffopt);
55 rev.diff = 1;
56 rev.diffopt.recursive = 1;
57 rev.simplify_history = 0;
@@ -64,8 +65,9 @@ int cmd_show(int argc, const char **argv, char **envp)
65 {
66 struct rev_info rev;
67
67 - git_config(git_diff_ui_config);
68 init_revisions(&rev);
69 + git_config(git_diff_ui_config);
70 + diff_setup(&rev.diffopt);
71 rev.diff = 1;
72 rev.diffopt.recursive = 1;
73 rev.combine_merges = 1;
@@ -81,8 +83,9 @@ int cmd_log(int argc, const char **argv, char **envp)
83 {
84 struct rev_info rev;
85
84 - git_config(git_diff_ui_config);
86 init_revisions(&rev);
87 + git_config(git_diff_ui_config);
88 + diff_setup(&rev.diffopt);
89 rev.always_show_header = 1;
90 cmd_log_init(argc, argv, envp, &rev);
91 return cmd_log_walk(&rev);