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

[PATCH v2 0/5] activate diff.renames by default

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Feb 25, 2016, 08:59 UTC
Message-ID
<1456390761-27015-1-git-send-email-Matthieu.Moy@imag.fr>
In-Reply-To
<1456249498-3232-1-git-send-email-Matthieu.Moy@imag.fr>
Remarks on v1 applied:
* document that diff.renames applies only to porcelain
* use <<- instead of << in tests
* rename git_diff_ui_default_config to init_diff_ui_defaults
* f() -> f(void)
Interdiff follows:
diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt
index fdf5a79..69389ae 100644
--- a/Documentation/diff-config.txt
+++ b/Documentation/diff-config.txt
@@ -111,7 +111,10 @@ diff.renames::
 	Whether and how Git detects renames.  If set to "false",
 	rename detection is disabled. If set to "true", basic rename
 	detection is enable.  If set to "copies" or "copy", Git will
-	detect copies, as well.  Defaults to true.
+	detect copies, as well.  Defaults to true.  Note that this
+	affects only 'git diff' Porcelain like linkgit:git-diff[1] and
+	linkgit:git-log[1], and not lower level commands such as
+	linkgit:git-diff-files[1].
 
 diff.suppressBlankEmpty::
 	A boolean to inhibit the standard behavior of printing a space
diff --git a/builtin/commit.c b/builtin/commit.c
index 3cb4843..109742e 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -186,7 +186,7 @@ static void status_init_config(struct wt_status *s, config_fn_t fn)
 	gitmodules_config();
 	git_config(fn, s);
 	determine_whence(s);
-	git_diff_ui_default_config();
+	init_diff_ui_defaults();
 	s->hints = advice_status_hints; /* must come after git_config() */
 }
 
diff --git a/builtin/diff.c b/builtin/diff.c
index 8bd1fd5..343c6b8 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -318,7 +318,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 
 	if (!no_index)
 		gitmodules_config();
-	git_diff_ui_default_config();
+	init_diff_ui_defaults();
 	git_config(git_diff_ui_config, NULL);
 
 	init_revisions(&rev, prefix);
diff --git a/builtin/log.c b/builtin/log.c
index 6e34df3..c05a5f6 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -103,7 +103,7 @@ static int log_line_range_callback(const struct option *option, const char *arg,
 static void init_log_defaults()
 {
 	init_grep_defaults();
-	git_diff_ui_default_config();
+	init_diff_ui_defaults();
 }
 
 static void cmd_log_init_defaults(struct rev_info *rev)
diff --git a/builtin/merge.c b/builtin/merge.c
index cf297d4..4cb4f6a 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1187,7 +1187,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 	else
 		head_commit = lookup_commit_or_die(head_sha1, "HEAD");
 
-	git_diff_ui_default_config();
+	init_diff_ui_defaults();
 	git_config(git_merge_config, NULL);
 
 	if (branch_mergeoptions)
diff --git a/diff.c b/diff.c
index d5db898..b4dea07 100644
--- a/diff.c
+++ b/diff.c
@@ -168,7 +168,7 @@ long parse_algorithm_value(const char *value)
  * never be affected by the setting of diff.renames
  * the user happens to have in the configuration file.
  */
-void git_diff_ui_default_config()
+void init_diff_ui_defaults(void)
 {
 	diff_detect_rename_default = 1;
 }
diff --git a/diff.h b/diff.h
index 75686d5..0a3ce86 100644
--- a/diff.h
+++ b/diff.h
@@ -266,7 +266,7 @@ extern int parse_long_opt(const char *opt, const char **argv,
 			 const char **optarg);
 
 extern int git_diff_basic_config(const char *var, const char *value, void *cb);
-extern void git_diff_ui_default_config();
+extern void init_diff_ui_defaults(void);
 extern int git_diff_ui_config(const char *var, const char *value, void *cb);
 extern void diff_setup(struct diff_options *);
 extern int diff_opt_parse(struct diff_options *, const char **, int, const char *);
diff --git a/t/t4001-diff-rename.sh b/t/t4001-diff-rename.sh
index 15d99a3..c7e58b6 100755
--- a/t/t4001-diff-rename.sh
+++ b/t/t4001-diff-rename.sh
@@ -10,83 +10,83 @@ test_description='Test rename detection in diff engine.
 . "$TEST_DIRECTORY"/diff-lib.sh
 
 test_expect_success 'setup' '
-	cat >path0 <<\EOF &&
-Line 1
-Line 2
-Line 3
-Line 4
-Line 5
-Line 6
-Line 7
-Line 8
-Line 9
-Line 10
-line 11
-Line 12
-Line 13
-Line 14
-Line 15
-EOF
-	cat >expected <<\EOF &&
-diff --git a/path0 b/path1
-rename from path0
-rename to path1
---- a/path0
-+++ b/path1
-@@ -8,7 +8,7 @@ Line 7
- Line 8
- Line 9
- Line 10
--line 11
-+Line 11
- Line 12
- Line 13
- Line 14
-EOF
-	cat >no-rename <<\EOF
-diff --git a/path0 b/path0
-deleted file mode 100644
-index fdbec44..0000000
---- a/path0
-+++ /dev/null
-@@ -1,15 +0,0 @@
--Line 1
--Line 2
--Line 3
--Line 4
--Line 5
--Line 6
--Line 7
--Line 8
--Line 9
--Line 10
--line 11
--Line 12
--Line 13
--Line 14
--Line 15
-diff --git a/path1 b/path1
-new file mode 100644
-index 0000000..752c50e
---- /dev/null
-+++ b/path1
-@@ -0,0 +1,15 @@
-+Line 1
-+Line 2
-+Line 3
-+Line 4
-+Line 5
-+Line 6
-+Line 7
-+Line 8
-+Line 9
-+Line 10
-+Line 11
-+Line 12
-+Line 13
-+Line 14
-+Line 15
-EOF
+	cat >path0 <<-\EOF &&
+	Line 1
+	Line 2
+	Line 3
+	Line 4
+	Line 5
+	Line 6
+	Line 7
+	Line 8
+	Line 9
+	Line 10
+	line 11
+	Line 12
+	Line 13
+	Line 14
+	Line 15
+	EOF
+	cat >expected <<-\EOF &&
+	diff --git a/path0 b/path1
+	rename from path0
+	rename to path1
+	--- a/path0
+	+++ b/path1
+	@@ -8,7 +8,7 @@ Line 7
+	 Line 8
+	 Line 9
+	 Line 10
+	-line 11
+	+Line 11
+	 Line 12
+	 Line 13
+	 Line 14
+	EOF
+	cat >no-rename <<-\EOF
+	diff --git a/path0 b/path0
+	deleted file mode 100644
+	index fdbec44..0000000
+	--- a/path0
+	+++ /dev/null
+	@@ -1,15 +0,0 @@
+	-Line 1
+	-Line 2
+	-Line 3
+	-Line 4
+	-Line 5
+	-Line 6
+	-Line 7
+	-Line 8
+	-Line 9
+	-Line 10
+	-line 11
+	-Line 12
+	-Line 13
+	-Line 14
+	-Line 15
+	diff --git a/path1 b/path1
+	new file mode 100644
+	index 0000000..752c50e
+	--- /dev/null
+	+++ b/path1
+	@@ -0,0 +1,15 @@
+	+Line 1
+	+Line 2
+	+Line 3
+	+Line 4
+	+Line 5
+	+Line 6
+	+Line 7
+	+Line 8
+	+Line 9
+	+Line 10
+	+Line 11
+	+Line 12
+	+Line 13
+	+Line 14
+	+Line 15
+	EOF
 '
 
 test_expect_success \




Matthieu Moy (5):
  Documentation/diff-config: fix description of diff.renames
  t4001-diff-rename: wrap file creations in a test
  t: add tests for diff.renames (true/false/unset)
  log: introduce init_log_defaults()
  diff: activate diff.renames by default

 Documentation/diff-config.txt |  10 +++-
 builtin/commit.c              |   1 +
 builtin/diff.c                |   1 +
 builtin/log.c                 |  16 ++++--
 builtin/merge.c               |   1 +
 diff.c                        |   5 ++
 diff.h                        |   1 +
 t/t4001-diff-rename.sh        | 125 +++++++++++++++++++++++++++++++-----------
 t/t4013-diff-various.sh       |   2 +
 t/t4014-format-patch.sh       |   4 +-
 t/t4047-diff-dirstat.sh       |   3 +-
 t/t4202-log.sh                |   8 +--
 12 files changed, 131 insertions(+), 46 deletions(-)
-- 
2.7.2.334.g35ed2ae.dirty
Previous: Junio C HamanoNext: Matthieu Moy
Message 19 of 29 in “activate diff.renames by default”
  1. 0/5 activate diff.renames by defaultMatthieu Moy, Feb 23, 2016
  2. 1/5 Documentation/diff-config: fix description of diff.renamesMatthieu Moy, Feb 23, 2016
  3. Jeff KingFeb 24, 2016
  4. Felipe Gonçalves AssisFeb 25, 2016
  5. Matthieu MoyFeb 25, 2016
  6. 2/5 t4001-diff-rename: wrap file creations in a testMatthieu Moy, Feb 23, 2016
  7. Jeff KingFeb 24, 2016
  8. Matthieu MoyFeb 24, 2016
  9. 3/5 t: add tests for diff.renames (true/false/unset)Matthieu Moy, Feb 23, 2016
  10. 4/5 log: introduce init_log_defaults()Matthieu Moy, Feb 23, 2016
  11. 5/5 diff: activate diff.renames by defaultMatthieu Moy, Feb 23, 2016
  12. Junio C HamanoFeb 23, 2016
  13. Matthieu MoyFeb 23, 2016
  14. Jeff KingFeb 24, 2016
  15. Matthieu MoyFeb 25, 2016
  16. Junio C HamanoFeb 23, 2016
  17. Matthieu MoyFeb 23, 2016
  18. Junio C HamanoFeb 23, 2016
  19. 0/5 activate diff.renames by defaultMatthieu Moy, Feb 25, 2016
  20. 1/5 Documentation/diff-config: fix description of diff.renamesMatthieu Moy, Feb 25, 2016
  21. Documentation/diff-config: fix description of diff.renamesMatthieu Moy, Feb 25, 2016
  22. Junio C HamanoFeb 25, 2016
  23. Junio C HamanoFeb 25, 2016
  24. 2/5 t4001-diff-rename: wrap file creations in a testMatthieu Moy, Feb 25, 2016
  25. 3/5 t: add tests for diff.renames (true/false/unset)Matthieu Moy, Feb 25, 2016
  26. 4/5 log: introduce init_log_defaults()Matthieu Moy, Feb 25, 2016
  27. Junio C HamanoFeb 25, 2016
  28. 5/5 diff: activate diff.renames by defaultMatthieu Moy, Feb 25, 2016
  29. Junio C HamanoFeb 25, 2016

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.