git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] wt-status: use rename settings from init_diff_ui_defaults

From
Eckhard S. Maaß <eckhard.s.maass@googlemail.com>
Date
May 1, 2018, 09:49 UTC
Message-ID
<20180501094940.17772-1-eckhard.s.maass@gmail.com>
In-Reply-To
<c466854f-6087-e7f1-264a-1d2df9fd9b5a@gmail.com>

Since the very beginning, git status behaved differently for rename detection than other rename aware commands like git log or git show as it has the use of rename hard coded into it. After 5404c116aa ("diff: activate diff.renames by default", 2016-02-25) the default behaves the same by coincidence, but a work flow like

    - git add .
    - git status
    - git commit
    - git show

should give you the same information on renames (and/or copies if activated) accordingly to the diff.renames and diff.renameLimit setting.

With this commit the hard coded settings are dropped from the status command.

Signed-off-by: Eckhard S. Maaß <eckhard.s.maass@gmail.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
---
 builtin/commit.c       |  2 +-
 t/t4001-diff-rename.sh | 12 ++++++++++++
 wt-status.c            |  4 ----
 3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 5571d4a3e2..5240f11225 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -161,9 +161,9 @@ static void determine_whence(struct wt_status *s)
 static void status_init_config(struct wt_status *s, config_fn_t fn)
 {
 	wt_status_prepare(s);
+	init_diff_ui_defaults();
 	git_config(fn, s);
 	determine_whence(s);
-	init_diff_ui_defaults();
 	s->hints = advice_status_hints; /* must come after git_config() */
 }
 
diff --git a/t/t4001-diff-rename.sh b/t/t4001-diff-rename.sh
index a07816d560..bf4030371a 100755
--- a/t/t4001-diff-rename.sh
+++ b/t/t4001-diff-rename.sh
@@ -138,6 +138,18 @@ test_expect_success 'favour same basenames over different ones' '
 	test_i18ngrep "renamed: .*path1 -> subdir/path1" out
 '
 
+test_expect_success 'test diff.renames=true for git status' '
+	git -c diff.renames=true status >out &&
+	test_i18ngrep "renamed: .*path1 -> subdir/path1" out
+'
+
+test_expect_success 'test diff.renames=false for git status' '
+	git -c diff.renames=false status >out &&
+	test_i18ngrep ! "renamed: .*path1 -> subdir/path1" out &&
+	test_i18ngrep "new file: .*subdir/path1" out &&
+	test_i18ngrep "deleted: .*[^/]path1" out
+'
+
 test_expect_success 'favour same basenames even with minor differences' '
 	git show HEAD:path1 | sed "s/15/16/" > subdir/path1 &&
 	git status >out &&
diff --git a/wt-status.c b/wt-status.c
index 50815e5faf..32f3bcaebd 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -625,9 +625,6 @@ static void wt_status_collect_changes_index(struct wt_status *s)
 	rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
 	rev.diffopt.format_callback = wt_status_collect_updated_cb;
 	rev.diffopt.format_callback_data = s;
-	rev.diffopt.detect_rename = DIFF_DETECT_RENAME;
-	rev.diffopt.rename_limit = 200;
-	rev.diffopt.break_opt = 0;
 	copy_pathspec(&rev.prune_data, &s->pathspec);
 	run_diff_index(&rev, 1);
 }
@@ -985,7 +982,6 @@ static void wt_longstatus_print_verbose(struct wt_status *s)
 	setup_revisions(0, NULL, &rev, &opt);
 
 	rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
-	rev.diffopt.detect_rename = DIFF_DETECT_RENAME;
 	rev.diffopt.file = s->fp;
 	rev.diffopt.close_file = 0;
 	/*
-- 
2.17.0.252.gfe0a9eaf31
Next: Ævar Arnfjörð Bjarmason
Message 1 of 14 in “wt-status: use rename settings from init_diff_ui_defaults”
  1. wt-status: use rename settings from init_diff_ui_defaultsEckhard S. Maaß, May 1, 2018
  2. Ævar Arnfjörð BjarmasonMay 1, 2018
  3. Eckhard MaaßMay 1, 2018
  4. Matthieu MoyMay 1, 2018
  5. Eckhard MaaßMay 1, 2018
  6. Matthieu MoyMay 1, 2018
  7. Elijah NewrenMay 1, 2018
  8. Junio C HamanoMay 1, 2018
  9. Elijah NewrenMay 2, 2018
  10. Ben PeartMay 2, 2018
  11. Eckhard MaaßMay 3, 2018
  12. wt-status: use settings from git_diff_ui_configEckhard S. Maaß, May 4, 2018
  13. Elijah NewrenMay 4, 2018
  14. Eckhard MaaßMay 1, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.