• [gentoo-dev] Reviewing ebuilds with git

    From Sam James@21:1/5 to All on Sun Jun 30 19:40:01 2024
    --=-=-=
    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/20240311213928.1872437-1-sam@gentoo.org

    From 2b9b8903fcc3815415f0d22a4646794757fc001a Mon Sep 17 00:00:00 2001
    From: Sam James <sam@gentoo.org>
    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 <sam@gentoo.org>
    ---
    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
  • From Martin Dummer@21:1/5 to All on Sun Jun 30 21:50:01 2024
    Am 30.06.24 um 21:18 schrieb Vitaly Zdanevich:
    Should this patch be added to git ebuild patch folder, with a new USE
    flag?

    That is possible, but you can add patches to ebuilds on your own:

    Create a directory:

    mkdir -p /etc/portage/patches/dev-vcs/git/

    and store the patch file from Sam's email into this directory. Then do a "emerge -1 dev-vcs/git" and you should be able to see that your "user
    patch" is applied to the current and every new git version.

    see also https://wiki.gentoo.org/wiki//etc/portage/patches

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Vitaly Zdanevich@21:1/5 to Sam James on Sun Jun 30 21:20:01 2024
    Should this patch be added to git ebuild patch folder, with a new USE flag?

    On 6/30/24 21:38, Sam James wrote:
    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.


    thanks,
    sam


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jaco Kroon@21:1/5 to Sam James on Wed Jul 3 11:10:01 2024
    Hi,

    Is there a way to make this work with github PR reviews?

    Kind regards,
    Jaco

    On 2024/06/30 19:38, Sam James wrote:

    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.


    thanks,
    sam


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)