From: "Nuthan Munaiah" <nm6061@rit.edu>
To: git@vger.kernel.org
Subject: `git blame` Line Number Off-by-one
Date: Fri, 07 Aug 2020 01:05:51 +0000 [thread overview]
Message-ID: <emc6590292-832a-4a35-8815-d5707731d605@sanctum> (raw)
What did you do before the bug happened? (Steps to reproduce your issue)
* Clone https://github.com/apache/tomcat
* Run `git blame --root -leftw -L 21,21 -L 23,23
51844327d8613448bb0bf9667e1a61e462e2043c^ --
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java`
What did you expect to happen? (Expected behavior)
`git blame` shows the last commit that modified lines 21 and 23 of
`modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java`
starting at the parent of `51844327d8613448bb0bf9667e1a61e462e2043c`.
```
$ git blame --root -leftw -L 21,21 -L 23,23
51844327d8613448bb0bf9667e1a61e462e2043c^ --
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
c65a429f06f4e4a025a306e377211863d9ff2a0c
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
(<fhanik@apache.org> 1226896977 +0000 21) import java.util.ArrayList;
c65a429f06f4e4a025a306e377211863d9ff2a0c
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
(<fhanik@apache.org> 1226896977 +0000 23) import java.util.List;
```
What happened instead? (Actual behavior)
Line 23 is not shown in the `git blame` output. Instead, line 22 is
shown.
```
$ git blame --root -leftw -L 21,21 -L 23,23
51844327d8613448bb0bf9667e1a61e462e2043c^ --
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
c65a429f06f4e4a025a306e377211863d9ff2a0c
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
(<fhanik@apache.org> 1226896977 +0000 21) import java.util.ArrayList;
c65a429f06f4e4a025a306e377211863d9ff2a0c
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
(<fhanik@apache.org> 1226896977 +0000 22) import java.util.HashMap;
```
What's different between what you expected and what actually happened?
Line 23 is not shown in the `git blame` output. Instead line 22 is
shown.
Anything else you want to add:
* The issue is reproducible on git versions 2.28.0 (on Ubuntu 18.04.4
LTS), 2.24.0 (on Ubuntu 18.04.3 LTS), 2.17.0 (on Ubuntu 18.04.4 LTS),
and 2.27.0.windows.1 (on Microsoft Windows 10 Enterprise 10.0.19041
Build 19041).
* The addition of `--porcelain` does not resolve the issue.
* The issue is not specific to a particular repository. For instance,
the output from `git blame -L 1466,1466 -L 1468,1468
35e69fc7cf9421ab04ffc9d52cb36d07fa12984a^ -- c/dec/decode.c` in a clone
of https://github.com/google/brotli shows last commit that modified
lines 1466 and 1467 (instead 1468).
* The issue seems to present itself only when there is exactly one line
in between two specifications of `-L`. For instance, `-L 20,20 -L 23,23`
correctly blames lines 20 and 23, `-L 20,20 -L 21,21 -L 22,22 -L 23,23`
correctly blames lines 20, 21, 22, and 23, `-L 23,23` correctly blames
line 23, but `-L 21,21 -L 23,23` blames lines 21 and 22 (instead of 23).
[System Info]
git version:
git version 2.28.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 4.15.0-88-generic #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC
2020 x86_64
compiler info: gnuc: 7.5
libc info: glibc: 2.27
$SHELL (typically, interactive shell): <unset>
[Enabled Hooks]
next reply other threads:[~2020-08-07 1:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-07 1:05 Nuthan Munaiah [this message]
2020-08-07 21:21 ` `git blame` Line Number Off-by-one Jeff King
2020-08-07 21:33 ` Jeff King
2020-08-07 21:45 ` Jeff King
2020-08-07 22:05 ` Junio C Hamano
2020-08-07 22:26 ` Jeff King
2020-08-07 22:35 ` Jeff King
2020-08-13 5:20 ` [PATCH 0/3] blame: fix bug in coalescing non-adjacent "-L" chunks Jeff King
2020-08-13 5:23 ` [PATCH 1/3] t8003: check output of coalesced blame Jeff King
2020-08-13 17:04 ` Junio C Hamano
2020-08-13 17:22 ` Jeff King
2020-08-13 5:23 ` [PATCH 2/3] t8003: factor setup out of coalesce test Jeff King
2020-08-13 5:25 ` [PATCH 3/3] blame: only coalesce lines that are adjacent in result Jeff King
2020-08-13 16:59 ` Junio C Hamano
2020-08-13 18:41 ` Junio C Hamano
2020-08-13 12:25 ` [PATCH 0/3] blame: fix bug in coalescing non-adjacent "-L" chunks Barret Rhoden
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=emc6590292-832a-4a35-8815-d5707731d605@sanctum \
--to=nm6061@rit.edu \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).