Skip to content

Commit dc6b1d9

Browse files
seckiigitster
authored andcommitted
wt-status: use settings from git_diff_ui_config
If you do something like - git add . - git status - git commit - git show (or git diff HEAD) one would expect to have analogous output from git status and git show (or similar diff-related programs). This is generally not the case, as git status has hard coded values for diff related options. With this commit the hard coded settings are dropped from the status command in favour for values provided by git_diff_ui_config. What follows are some remarks on the concrete options which were hard coded in git status: diffopt.detect_rename Since the very beginning of git status in a3e870f ("Add "commit" helper script", 2005-05-30), git status always used rename detection, whereas with commands like show and log one had to activate it with a command line option. After 5404c11 ("diff: activate diff.renames by default", 2016-02-25) the default behaves the same by coincidence, but changing diff.renames to other values can break the consistency between git status and other commands again. With this commit one control the same default behaviour with diff.renames. diffopt.rename_limit Similarly one has the option diff.renamelimit to adjust this limit for all commands but git status. With this commit git status will also honor those. diffopt.break_opt Unlike the other two options this cannot be configured by a configuration option yet. This commit will also change the default behaviour to not use break rewrites. But as rename detection is most likely on, this is dangerous to be activated anyway as one can see here: https://public-inbox.org/git/[email protected]/ Signed-off-by: Eckhard S. Maaß <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1f1cddd commit dc6b1d9

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ static void determine_whence(struct wt_status *s)
161161
static void status_init_config(struct wt_status *s, config_fn_t fn)
162162
{
163163
wt_status_prepare(s);
164+
init_diff_ui_defaults();
164165
git_config(fn, s);
165166
determine_whence(s);
166-
init_diff_ui_defaults();
167167
s->hints = advice_status_hints; /* must come after git_config() */
168168
}
169169

t/t4001-diff-rename.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ test_expect_success 'favour same basenames over different ones' '
138138
test_i18ngrep "renamed: .*path1 -> subdir/path1" out
139139
'
140140

141+
test_expect_success 'test diff.renames=true for git status' '
142+
git -c diff.renames=true status >out &&
143+
test_i18ngrep "renamed: .*path1 -> subdir/path1" out
144+
'
145+
146+
test_expect_success 'test diff.renames=false for git status' '
147+
git -c diff.renames=false status >out &&
148+
test_i18ngrep ! "renamed: .*path1 -> subdir/path1" out &&
149+
test_i18ngrep "new file: .*subdir/path1" out &&
150+
test_i18ngrep "deleted: .*[^/]path1" out
151+
'
152+
141153
test_expect_success 'favour same basenames even with minor differences' '
142154
git show HEAD:path1 | sed "s/15/16/" > subdir/path1 &&
143155
git status >out &&

wt-status.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,6 @@ static void wt_status_collect_changes_index(struct wt_status *s)
625625
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
626626
rev.diffopt.format_callback = wt_status_collect_updated_cb;
627627
rev.diffopt.format_callback_data = s;
628-
rev.diffopt.detect_rename = DIFF_DETECT_RENAME;
629-
rev.diffopt.rename_limit = 200;
630-
rev.diffopt.break_opt = 0;
631628
copy_pathspec(&rev.prune_data, &s->pathspec);
632629
run_diff_index(&rev, 1);
633630
}
@@ -985,7 +982,6 @@ static void wt_longstatus_print_verbose(struct wt_status *s)
985982
setup_revisions(0, NULL, &rev, &opt);
986983

987984
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
988-
rev.diffopt.detect_rename = DIFF_DETECT_RENAME;
989985
rev.diffopt.file = s->fp;
990986
rev.diffopt.close_file = 0;
991987
/*

0 commit comments

Comments
 (0)