--=-=-=
Content-Type: text/plain
Hi,
I've mentioned this on IRC a bunch of times to people but I figure I'll
mention it here in case anyone finds it useful.
Our use of git doesn't lend itself well to the default mode `git diff`
and friends operate in, as we create many new files rather than solely
changing existing ones.
git can be coerced into checking for copies (and doing so "harder" too)
but there's no configuration option for this, and it's a pain to
remember.
You can use the attached patch for dev-vcs/git and then set:
$ git config diff.renames copies-harder
in gentoo.git to make `git log -p`, `git diff`, etc default to this
mode.
IME, it makes reviewing much easier. Be warned that it does make git log
a bit slower though if the config option is enabled for a repo -- but
maybe only noticeably if your repo is grafted with the pre-2015 CVS history.
--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
filename=0001-diff-implement-config.diff.renames-copies-harder.patch Content-Transfer-Encoding: quoted-printable
Content-Description: copies harder patch
https://lore.kernel.org/git/[email protected]
From 2b9b8903fcc3815415f0d22a4646794757fc001a Mon Sep 17 00:00:00 2001
From: Sam James <
[email protected]>
Date: Fri, 16 Feb 2024 22:07:54 +0000
Subject: [PATCH 1/2] diff: implement config.diff.renames=copies-harder
This patch adds a config value for 'diff.renames' called 'copies-harder'
which make it so '-C -C' is in effect always passed for 'git log -p',
'git diff', etc.
This allows specifying that 'git log -p', 'git diff', etc should always act
as if '-C --find-copies-harder' was passed.
It has proven this especially useful for certain types of repository (like Gentoo's ebuild repositories) because files are often copies of a previous version:
Suppose a directory 'sys-devel/gcc' contains recipes for building
GCC, with one file for each supported upstream branch:
gcc-13.x.build.recipe
gcc-12.x.build.recipe
gcc-11.x.build.recipe
gcc-10.x.build.recipe
gcc-13.x.build.recipe was started as a copy of gcc-12.x.build.recipe
(which was started as a copy of gcc-11.x.build.recipe, etc.). Previous versions are kept around to support parallel installation of multiple versions.
Being able to easily observe the diff relative to other recipes within the directory has been a quality of life improvement for such repo layouts.
Signed-off-by: Sam James <
[email protected]>
---
Documentation/config/diff.txt | 8 +++++---
Documentation/config/status.txt | 4 +++-
diff.c | 11 +++++++++--
diff.h | 1 +
diffcore-rename.c | 6 ++++--
merge-ort.c | 2 +-
merge-recursive.c | 2 +-
7 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/Documentation/config/diff.txt b/Documentation/config/diff.txt index bd5ae0c337..cdd8a74ec0 100644
--- a/Documentation/config/diff.txt
+++ b/Documentation/config/diff.txt
@@ -131,9 +131,11 @@ diff.renames::
Whether and how Git detects renames. If set to "false",
rename detection is disabled. If set to "true", basic rename
detection is enabled. If set to "copies" or "copy", Git will
- 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
+ detect copies, as well. If set to "copies-hard