From: Tim Tassonis <stuff@decentral.ch>
To: Nikita Makarov <n.makarov@yadro.com>,
"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Bugreport: git log -L
Date: Mon, 21 Sep 2026 20:04:45 +0200 [thread overview]
Message-ID: <b6600538-afdd-4402-ad2c-2a5380b6c0cd@decentral.ch> (raw)
In-Reply-To: <41c54b809eb1490fb467ba0fd4c5a8cf@yadro.com>
On 9/21/26 09:45, Nikita Makarov wrote:
> Hello, I have the found the strange behavior of "git log -L" command with python function.
> It is counting a blank line that sits after a function's last statement as part of that function.
> This happens only when the function is at the end of a file.
>
> The way to reproduce that
>
> git init repro && cd repro
> git config user.email t@t && git config user.name t
>
> printf 'def foo():\n return 1\n\n' > bug.py
> git add bug.py && git commit -qm c1
>
> printf 'def foo():\n return 1\n' > bug.py
> git add bug.py && git commit -qm c2
>
> Then do
>
> git log -L :'foo':bug.py
>
> And you'll see
>
> Author: t <t@t>
> Date: Fri Sep 18 18:21:10 2026 +0300
>
> c2
>
> diff --git a/bug.py b/bug.py
> --- a/bug.py
> +++ b/bug.py
> @@ -1,2 +1,3 @@
> def foo():
> return 1
> +
>
> Though I expect that commit "c2" should never appear in log, since the changes from it doesn't affect the functions body at all.
From git log --help
...
If :<funcname> is given in place of <start> and <end>, it is a
regular expression that denotes the range from the first funcname
line that matches <funcname>, up to the next funcname line.
:<funcname> searches from the end of the previous -L range, if any,
otherwise from the start of file. ^:<funcname> searches from the
start of file. The function names are determined in the same way as
git diff works out patch hunk headers (see Defining a custom
hunk-header in gitattributes(5)).
..
So, the bug is rather the expectation that such a thing can reliably
know what a function is, regardless of coding style and language used.
To quote the late and great Christopher Tolkien: This could only be
achieved. if at all, at heavy and needless cost.
Bye>
> [System Info]
> git version:
> git version 2.43.0
> cpu: x86_64
> no commit associated with this build
> sizeof-long: 8
> sizeof-size_t: 8
> shell-path: /bin/sh
> uname: Linux 7.0.0-31-generic #31~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Aug 10 09:38:02 UTC 2 x86_64
> compiler info: gnuc: 13.3
> libc info: glibc: 2.39
> $SHELL (typically, interactive shell): /bin/bash
>
>
> [Enabled Hooks]
--
decentral.ch - IT Stuff
Tim Tassonis
Badenerstrasse 219
8003 Zürich
stuff@decentral.ch
+41 79 229 36 17
prev parent reply other threads:[~2026-09-21 18:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 7:45 Bugreport: git log -L Nikita Makarov
2026-09-21 9:49 ` Kristofer Karlsson
2026-09-21 16:40 ` Johannes Sixt
2026-09-21 18:04 ` Tim Tassonis [this message]
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=b6600538-afdd-4402-ad2c-2a5380b6c0cd@decentral.ch \
--to=stuff@decentral.ch \
--cc=git@vger.kernel.org \
--cc=n.makarov@yadro.com \
/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