Skip to content

Commit

Permalink
diff: do not use configuration magic at the core-level
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Jul 8, 2006
1 parent b537664 commit 83ad63c
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion builtin-diff-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int cmd_diff_files(int argc, const char **argv, char **envp)
struct rev_info rev;
int silent = 0;

git_config(git_diff_config);
git_config(git_default_config); /* no "diff" UI options */
init_revisions(&rev);
rev.abbrev = 0;

Expand Down
2 changes: 1 addition & 1 deletion builtin-diff-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int cmd_diff_index(int argc, const char **argv, char **envp)
int cached = 0;
int i;

git_config(git_diff_config);
git_config(git_default_config); /* no "diff" UI options */
init_revisions(&rev);
rev.abbrev = 0;

Expand Down
2 changes: 1 addition & 1 deletion builtin-diff-stages.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int cmd_diff_stages(int ac, const char **av, char **envp)
const char *prefix = setup_git_directory();
const char **pathspec = NULL;

git_config(git_diff_config);
git_config(git_default_config); /* no "diff" UI options */
read_cache();
diff_setup(&diff_options);
while (1 < ac && av[1][0] == '-') {
Expand Down
2 changes: 1 addition & 1 deletion builtin-diff-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int cmd_diff_tree(int argc, const char **argv, char **envp)
static struct rev_info *opt = &log_tree_opt;
int read_stdin = 0;

git_config(git_diff_config);
git_config(git_default_config); /* no "diff" UI options */
nr_sha1 = 0;
init_revisions(opt);
opt->abbrev = 0;
Expand Down
2 changes: 1 addition & 1 deletion builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ int cmd_diff(int argc, const char **argv, char **envp)
* Other cases are errors.
*/

git_config(git_diff_config);
git_config(git_diff_ui_config);
init_revisions(&rev);

argc = setup_revisions(argc, argv, &rev, NULL);
Expand Down
8 changes: 4 additions & 4 deletions builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int cmd_whatchanged(int argc, const char **argv, char **envp)
{
struct rev_info rev;

git_config(git_diff_config);
git_config(git_diff_ui_config);
init_revisions(&rev);
rev.diff = 1;
rev.diffopt.recursive = 1;
Expand All @@ -62,7 +62,7 @@ int cmd_show(int argc, const char **argv, char **envp)
{
struct rev_info rev;

git_config(git_diff_config);
git_config(git_diff_ui_config);
init_revisions(&rev);
rev.diff = 1;
rev.diffopt.recursive = 1;
Expand All @@ -79,7 +79,7 @@ int cmd_log(int argc, const char **argv, char **envp)
{
struct rev_info rev;

git_config(git_diff_config);
git_config(git_diff_ui_config);
init_revisions(&rev);
rev.always_show_header = 1;
cmd_log_init(argc, argv, envp, &rev);
Expand All @@ -105,7 +105,7 @@ static int git_format_config(const char *var, const char *value)
strcat(extra_headers, value);
return 0;
}
return git_diff_config(var, value);
return git_diff_ui_config(var, value);
}


Expand Down
8 changes: 7 additions & 1 deletion diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ static const char *parse_diff_color_value(const char *value, const char *var)
die("bad config value '%s' for variable '%s'", value, var);
}

int git_diff_config(const char *var, const char *value)
/*
* These are to give UI layer defaults.
* The core-level commands such as git-diff-files should
* never be affected by the setting of diff.renames
* the user happens to have in the configuration file.
*/
int git_diff_ui_config(const char *var, const char *value)
{
if (!strcmp(var, "diff.renamelimit")) {
diff_rename_limit_default = git_config_int(var, value);
Expand Down
2 changes: 1 addition & 1 deletion diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ extern int diff_scoreopt_parse(const char *opt);
#define DIFF_SETUP_USE_CACHE 2
#define DIFF_SETUP_USE_SIZE_CACHE 4

extern int git_diff_config(const char *var, const char *value);
extern int git_diff_ui_config(const char *var, const char *value);
extern void diff_setup(struct diff_options *);
extern int diff_opt_parse(struct diff_options *, const char **, int);
extern int diff_setup_done(struct diff_options *);
Expand Down

0 comments on commit 83ad63c

Please sign in to comment.