diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-09-18 10:07:01 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-09-18 10:07:01 -0700 |
| commit | cf47560e945f3d9a0a42e89b9d6ef59fb085bbb5 (patch) | |
| tree | af99257e449a457fe0b997b83f9c454dc072f720 /line-log.c | |
| parent | d680fe4996940b914ace65468a47ad6afe6d740b (diff) | |
| parent | e3106998ff84c9e1b548b72e0b034ca837d6c06b (diff) | |
| download | git-cf47560e945f3d9a0a42e89b9d6ef59fb085bbb5.tar.xz | |
Merge branch 'sg/line-log-boundary-fixes'
A corner case bug in "git log -L..." has been corrected.
* 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.c | 15 |
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 */ |
