git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] line-log: small fixes
@ 2025-08-18 11:13 SZEDER Gábor
  2025-08-18 11:13 ` [PATCH 1/2] line-log: fix assertion error SZEDER Gábor
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: SZEDER Gábor @ 2025-08-18 11:13 UTC (permalink / raw)
  To: git; +Cc: Evgeni Chasnovski, SZEDER Gábor

On Thu, May 02, 2024 at 09:29:04PM +0300, Evgeni Chasnovski wrote:
> Calling `git log` with several `-L` flags can result in an error.
> 
> Steps to reproduce (on Linux):
> - Set up repo with a history:
>     - `mkdir log-line-assert`
>     - `cd log-line-assert`
>     - `git init`
>     - `echo "Line 1\nLine 2" > file`
>     - `git add .`
>     - `git commit -m 'Commit 1'`
>     - `echo "Line 3\nLine 4\nLine 5" >> file`
>     - `git add .`
>     - `git commit -m 'Commit 2'`
> - Execute the following command: `git log -L2,2:file -L4,4:file`
> 
> # What did you expect to happen? (Expected behavior)
> 
> Show log with evolution of lines 2 and 4.
> 
> # What happened instead? (Actual behavior)
> 
> An error with the following text:
> 
> ```
> git: line-log.c:73: range_set_append: Assertion `rs->nr == 0 ||
> rs->ranges[rs->nr-1].end <= a' failed.
> zsh: IOT instruction (core dumped)  git log -L2,2:file -L4,4:file
> ```

Thanks for reporting this issue!

As it turns out, merely specifying more than one line range is
insufficient to trigger this assertion error, we need a rather specific
interaction between the line numbers of two line ranges and a diff range.

The first patch fixes this issue, along with a couple of similar bugs to
make that command really work, because once the assertion error was fixed
we ended up in an endless loop, and once that was fixed the output was
wrong...

The second patch fixes another line-log output issue that I just happened
to stumble upon while testing the fixes in the first patch.


SZEDER Gábor (2):
  line-log: fix assertion error
  line-log: show all line ranges touched by the same diff range

 line-log.c                               | 15 +++-
 t/t4211-line-log.sh                      |  2 +
 t/t4211/sha1/expect.multiple             |  6 ++
 t/t4211/sha1/expect.no-assertion-error   | 90 ++++++++++++++++++++++++
 t/t4211/sha1/expect.two-ranges           |  6 ++
 t/t4211/sha256/expect.multiple           |  6 ++
 t/t4211/sha256/expect.no-assertion-error | 90 ++++++++++++++++++++++++
 t/t4211/sha256/expect.two-ranges         |  6 ++
 8 files changed, 218 insertions(+), 3 deletions(-)
 create mode 100644 t/t4211/sha1/expect.no-assertion-error
 create mode 100644 t/t4211/sha256/expect.no-assertion-error

-- 
2.51.0.rc2.346.g6515629ae9


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

end of thread, other threads:[~2025-08-18 19:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18 11:13 [PATCH 0/2] line-log: small fixes SZEDER Gábor
2025-08-18 11:13 ` [PATCH 1/2] line-log: fix assertion error SZEDER Gábor
2025-08-18 19:17   ` Junio C Hamano
2025-08-18 11:13 ` [PATCH 2/2] line-log: show all line ranges touched by the same diff range SZEDER Gábor
2025-08-18 11:25 ` [PATCH 0/2] line-log: small fixes SZEDER Gábor

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 NNTP newsgroup(s).