git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Abhijeetsingh Meena via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Cc: Kristoffer Haugsbakk <code@khaugsbakk.name>,
	Abhijeetsingh Meena <abhijeetsingh.github@gmail.com>,
	Abhijeetsingh Meena <abhijeet040403@gmail.com>
Subject: Re: [PATCH v2 1/2] blame: respect .git-blame-ignore-revs automatically
Date: Sun, 13 Oct 2024 16:18:29 +0100	[thread overview]
Message-ID: <0ac9d9a1-cb91-4b1c-bba1-022ecc485684@gmail.com> (raw)
In-Reply-To: <4ed930cab1b7f5e9738e73c7b9374d927a8acd94.1728707867.git.gitgitgadget@gmail.com>

Hi Abhijeetsingh

On 12/10/2024 05:37, Abhijeetsingh Meena via GitGitGadget wrote:
> From: Abhijeetsingh Meena <abhijeet040403@gmail.com>
> 
> git-blame(1) can ignore a list of commits with `--ignore-revs-file`.
> This is useful for marking uninteresting commits like formatting
> changes, refactors and whatever else should not be “blamed”.  Some
> projects even version control this file so that all contributors can
> use it; the conventional name is `.git-blame-ignore-revs`.
> 
> But each user still has to opt-in to the standard ignore list,
> either with this option or with the config `blame.ignoreRevsFile`.
> Let’s teach git-blame(1) to respect this conventional file in order
> to streamline the process.

It's good that the commit message now mentions the config setting. It 
would be helpful to explain why the original implementation deliberately 
decided not to implement a default file and explain why it is now a good 
idea to do so. Supporting a default file in addition to the files listed 
in blame.ignoreRevsFile config setting leaves us in an odd position 
compared to other settings which use a fixed name like .gitignore or 
have a default that can be overridden by a config setting like 
core.excludesFile or require a config setting to enable the feature like 
diff.orderFile.

I've left a couple of code comments below but really the most important 
things are to come up with a convincing reason for changing the behavior 
and figuring out how the default file should interact with the config 
setting.

> +	/*
> +	* By default, add .git-blame-ignore-revs to the list of files
> +	* containing revisions to ignore if it exists.
> +	*/
> +	if (access(".git-blame-ignore-revs", F_OK) == 0) {

There are some uses of "access(.., F_OK)" in our code base but it is 
more usual to call file_exists() these days.

> +		string_list_append(&ignore_revs_file_list, ".git-blame-ignore-revs");

If the user already has this path in their config we'll waste time 
parsing it twice. We could avoid that by using a "struct strset" rather 
than a "struct string_list". I don't think we have OPT_STRSET but it 
should be easy to add one by copying OPT_STRING_LIST.

> +    echo world >>hello.txt &&
> +    test_commit second-commit hello.txt &&

test_commit overwrites the file it is committing so you need to use the 
--printf option

	test_commit --printf second-commit hello.txt "hello\nworld\n"

> +    git rev-parse HEAD >ignored-file &&
> +    git blame --ignore-revs-file=ignored-file hello.txt >expect &&
> +    git rev-parse HEAD >.git-blame-ignore-revs &&
> +    git blame hello.txt >actual &&
> +    test_cmp expect actual

I have mixed feelings about this sort of differential testing, comparing 
the actual output of git blame to what we expect makes it unambiguous 
that the test is checking what we want it to.

Best Wishes

Phillip


  parent reply	other threads:[~2024-10-13 15:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08  7:01 [PATCH] blame: respect .git-blame-ignore-revs automatically Abhijeetsingh Meena via GitGitGadget
2024-10-08  9:07 ` Kristoffer Haugsbakk
2024-10-08  9:51 ` Phillip Wood
     [not found] ` <pull.1809.v2.git.1728397437637.gitgitgadget@gmail.com>
     [not found]   ` <CAAirc3j2MfLyiNVnseRmTsDDu6R4gkcms1GXk=9_jAVLvEYaUg@mail.gmail.com>
     [not found]     ` <CAAirc3gX=PBixcyR0NRyRDnrydkeeu8A9or90c8MSUdHQ6uo=w@mail.gmail.com>
2024-10-08 16:12       ` [PREVIEW v2] " Abhijeetsingh Meena
2024-10-08 16:12         ` Abhijeetsingh Meena
2024-10-12  4:37 ` [PATCH v2 0/2] " Abhijeetsingh Meena via GitGitGadget
2024-10-12  4:37   ` [PATCH v2 1/2] " Abhijeetsingh Meena via GitGitGadget
2024-10-12  6:07     ` Eric Sunshine
2024-10-12  6:43       ` Eric Sunshine
2024-10-14 21:08       ` Taylor Blau
2024-10-16  6:04       ` Abhijeetsingh Meena
2024-10-12 13:58     ` Kristoffer Haugsbakk
2024-10-13 15:25       ` Phillip Wood
2024-10-14 21:00         ` Kristoffer Haugsbakk
2024-10-16  6:06       ` Abhijeetsingh Meena
2024-10-13 15:18     ` Phillip Wood [this message]
2024-10-16  6:07       ` Abhijeetsingh Meena
2024-10-22  6:49         ` Abhijeetsingh Meena
2024-10-22  7:54           ` Eric Sunshine
2024-10-12  4:37   ` [PATCH v2 2/2] blame: introduce --override-ignore-revs to bypass ignore revisions list Abhijeetsingh Meena via GitGitGadget
2024-10-12  6:24     ` Eric Sunshine
2024-10-12  6:26       ` Eric Sunshine
2024-10-12 14:25     ` Kristoffer Haugsbakk
2024-10-13 15:20     ` Phillip Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0ac9d9a1-cb91-4b1c-bba1-022ecc485684@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=abhijeet040403@gmail.com \
    --cc=abhijeetsingh.github@gmail.com \
    --cc=code@khaugsbakk.name \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).