aboutsummaryrefslogtreecommitdiffstats
path: root/line-log.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-09-12 10:42:33 -0700
committerJunio C Hamano <gitster@pobox.com>2025-09-12 10:42:34 -0700
commit0d34d3872ca9b3dc0c02d33ca9885ccac724f118 (patch)
tree8f7a244b2c01a10f88af782b1c7690412234bf99 /line-log.c
parentMerge branch 'jc/doc-includeif-hasconfig-remote-url-fix' into next (diff)
parentline-log: show all line ranges touched by the same diff range (diff)
downloadgit-0d34d3872ca9b3dc0c02d33ca9885ccac724f118.tar.gz
git-0d34d3872ca9b3dc0c02d33ca9885ccac724f118.zip
Merge branch 'sg/line-log-boundary-fixes' into next
Fix for a corner case bug in "git log -L...". * sg/line-log-boundary-fixes: line-log: show all line ranges touched by the same diff range line-log: fix assertion error
Diffstat (limited to 'line-log.c')
-rw-r--r--line-log.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/line-log.c b/line-log.c
index 188d387d40..8bd422148d 100644
--- a/line-log.c
+++ b/line-log.c
@@ -201,7 +201,7 @@ static void range_set_difference(struct range_set *out,
* b: ------|
*/
j++;
- if (j >= b->nr || end < b->ranges[j].start) {
+ if (j >= b->nr || end <= b->ranges[j].start) {
/*
* b exhausted, or
* a: ----|
@@ -408,7 +408,7 @@ static void diff_ranges_filter_touched(struct diff_ranges *out,
assert(out->target.nr == 0);
for (i = 0; i < diff->target.nr; i++) {
- while (diff->target.ranges[i].start > rs->ranges[j].end) {
+ while (diff->target.ranges[i].start >= rs->ranges[j].end) {
j++;
if (j == rs->nr)
return;
@@ -939,9 +939,18 @@ static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *rang
long t_cur = t_start;
unsigned int j_last;
+ /*
+ * If a diff range touches multiple line ranges, then all
+ * those line ranges should be shown, so take a step back if
+ * the current line range is still in the previous diff range
+ * (even if only partially).
+ */
+ if (j > 0 && diff->target.ranges[j-1].end > t_start)
+ j--;
+
while (j < diff->target.nr && diff->target.ranges[j].end < t_start)
j++;
- if (j == diff->target.nr || diff->target.ranges[j].start > t_end)
+ if (j == diff->target.nr || diff->target.ranges[j].start >= t_end)
continue;
/* Scan ahead to determine the last diff that falls in this range */