Git development
 help / color / mirror / Atom feed
* Bugreport: git log -L
@ 2026-09-21  7:45 Nikita Makarov
  2026-09-21  9:49 ` Kristofer Karlsson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nikita Makarov @ 2026-09-21  7:45 UTC (permalink / raw)
  To: git@vger.kernel.org

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. 

[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]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-21 18:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox