git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* `git blame` Line Number Off-by-one
@ 2020-08-07  1:05 Nuthan Munaiah
  2020-08-07 21:21 ` Jeff King
  0 siblings, 1 reply; 16+ messages in thread
From: Nuthan Munaiah @ 2020-08-07  1:05 UTC (permalink / raw)
  To: git

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]


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

end of thread, other threads:[~2020-08-13 18:42 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-07  1:05 `git blame` Line Number Off-by-one Nuthan Munaiah
2020-08-07 21:21 ` 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

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).