# [PATCH] blame: only parse detailed commit info if needed

4 messages from 2025-07-22 to 2025-07-23. Participants: Han Young, Patrick Steinhardt, Junio C Hamano.
Thread: https://gitlist.dev/t/63819

## Han Young, 2025-07-22 11:42

Subject: [PATCH] blame: only parse detailed commit info if needed
Message-ID: <20250722114220.87570-1-hanyang.tony@bytedance.com>
URL: https://gitlist.dev/e/20250722114220.87570-1-hanyang.tony%40bytedance.com

```
In commit cee7f245d (git-pickaxe: blame rewritten., 2006-10-19),
The function get_commit_info can terminate commit parsing early if only
the author information is needed. This ability is not used by callers
who do not require detailed commit information. Stop requesting detailed
commit information for these callers.

Signed-off-by: Han Young <hanyang.tony@bytedance.com>
---
 builtin/blame.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index 91586e685..b6a38e530 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -471,7 +471,7 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int
 	int show_raw_time = !!(opt & OUTPUT_RAW_TIMESTAMP);
 	const char *default_color = NULL, *color = NULL, *reset = NULL;
 
-	get_commit_info(suspect->commit, &ci, 1);
+	get_commit_info(suspect->commit, &ci, 0);
 	oid_to_hex_r(hex, &suspect->commit->object.oid);
 
 	cp = blame_nth_line(sb, ent->lno);
@@ -665,7 +665,7 @@ static void find_alignment(struct blame_scoreboard *sb, int *option)
 		if (!(suspect->commit->object.flags & METAINFO_SHOWN)) {
 			struct commit_info ci = COMMIT_INFO_INIT;
 			suspect->commit->object.flags |= METAINFO_SHOWN;
-			get_commit_info(suspect->commit, &ci, 1);
+			get_commit_info(suspect->commit, &ci, 0);
 			if (*option & OUTPUT_SHOW_EMAIL)
 				num = utf8_strwidth(ci.author_mail.buf);
 			else
-- 
2.50.1.321.gea4e667e7


```

## Patrick Steinhardt, 2025-07-22 14:15

Subject: Re: [PATCH] blame: only parse detailed commit info if needed
Message-ID: <aH-dGhHm2xuY4yT3@pks.im>
URL: https://gitlist.dev/e/aH-dGhHm2xuY4yT3%40pks.im
In-Reply-To: <20250722114220.87570-1-hanyang.tony@bytedance.com>

```
On Tue, Jul 22, 2025 at 07:42:20PM +0800, Han Young wrote:
> In commit cee7f245d (git-pickaxe: blame rewritten., 2006-10-19),
> The function get_commit_info can terminate commit parsing early if only
> the author information is needed. This ability is not used by callers
> who do not require detailed commit information. Stop requesting detailed
> commit information for these callers.

Okay. I think there's two important pieces of information missing here:

  - What does this buy us? I guess the answer is performance, but it
    would be sure to quantify in which scenarios and how much of a
    speedup this buys us.

  - Any reasoning why those two callers don't need the information.
    Reviewers can try to piece it together manually, but it would be
    nice to hold their hand and lead them through the change.

Thanks!

Patrick

```

## Junio C Hamano, 2025-07-22 17:08

Subject: Re: [PATCH] blame: only parse detailed commit info if needed
Message-ID: <xmqq5xfktaq7.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq5xfktaq7.fsf%40gitster.g
In-Reply-To: <aH-dGhHm2xuY4yT3@pks.im>

```
Patrick Steinhardt <ps@pks.im> writes:

> On Tue, Jul 22, 2025 at 07:42:20PM +0800, Han Young wrote:
>> In commit cee7f245d (git-pickaxe: blame rewritten., 2006-10-19),
>> The function get_commit_info can terminate commit parsing early if only
>> the author information is needed. This ability is not used by callers
>> who do not require detailed commit information. Stop requesting detailed
>> commit information for these callers.
>
> Okay. I think there's two important pieces of information missing here:
>
>   - What does this buy us? I guess the answer is performance, but it
>     would be sure to quantify in which scenarios and how much of a
>     speedup this buys us.
>
>   - Any reasoning why those two callers don't need the information.
>     Reviewers can try to piece it together manually, but it would be
>     nice to hold their hand and lead them through the change.

Good questions to ask.  

If the answer to the first question is "well, not really?", then
another thing to consider would be if we want to remove that
short-cut as conditionally grabbing only just some pieces of
information without getting others is not helping.

Thanks.

```

## Han Young, 2025-07-23 06:02

Subject: Re: [External] Re: [PATCH] blame: only parse detailed commit info if needed
Message-ID: <CAG1j3zHn_wp-R6tOJqCFi+wKro_t0oNj+aHsnbLw+O66i2YvQQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAG1j3zHn_wp-R6tOJqCFi%2BwKro_t0oNj%2BaHsnbLw%2BO66i2YvQQ%40mail.gmail.com
In-Reply-To: <aH-dGhHm2xuY4yT3@pks.im>

```
On Tue, Jul 22, 2025 at 10:16 PM Patrick Steinhardt <ps@pks.im> wrote:
>   - What does this buy us? I guess the answer is performance, but it
>     would be sure to quantify in which scenarios and how much of a
>     speedup this buys us.
I actually ran some performance tests before submitting this patch,
On a 5000-line file with a fairly long history, running
"git blame --porcelain FILE" for 100 times, the speedup is less
than 1 second. Considering the total run time is 180 seconds, I think
the performance gain is negligible (the speed increase could even be
due to system noise).

> - Any reasoning why those two callers don't need the information.
> Reviewers can try to piece it together manually, but it would be
> nice to hold their hand and lead them through the change.
These two callers only access the author information part of the
commit_info struct, before discarding the commit_info object.
Sorry for not including this information in the patch description.

On Wed, Jul 23, 2025 at 1:08 AM Junio C Hamano <gitster@pobox.com> wrote:
> If the answer to the first question is "well, not really?", then
> another thing to consider would be if we want to remove that
> short-cut as conditionally grabbing only just some pieces of
> information without getting others is not helping.
All callers of the get_commit_info function request detailed
commit information. Removing the shortcut would reduce the
complexity of the codebase. I will send another patch to remove
the "detailed" param from the get_commit_info.

Thanks

```
