Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-07-25 06:19:24 +0400
committerJunio C Hamano <gitster@pobox.com>2013-07-25 06:19:24 +0400
commit1762224ddb599ab14ca26cedafec39dee9b92fe5 (patch)
tree89ba13e49e5e65c5e80e69602cba166ddc543a5b /line-log.c
parent6a907786af835ac15962be53f1492f23e044f479 (diff)
parentd3a486c47d920efc183645766d762fd697c42088 (diff)
Merge branch 'tr/line-log'
Fix "log -L" command line parsing bugs. * tr/line-log: t4211: fix incorrect rebase at f8395edc (range-set: satisfy non-empty ranges invariant) line-log: fix "log -LN" crash when N is last line of file range-set: satisfy non-empty ranges invariant t4211: demonstrate crash when first -L encountered is empty range t4211: demonstrate empty -L range crash range-set: fix sort_and_merge_range_set() corner case bug
Diffstat (limited to 'line-log.c')
-rw-r--r--line-log.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/line-log.c b/line-log.c
index 8cc29a0000..c2d01dccc2 100644
--- a/line-log.c
+++ b/line-log.c
@@ -110,12 +110,14 @@ static void range_set_check_invariants(struct range_set *rs)
static void sort_and_merge_range_set(struct range_set *rs)
{
int i;
- int o = 1; /* output cursor */
+ int o = 0; /* output cursor */
qsort(rs->ranges, rs->nr, sizeof(struct range), range_cmp);
- for (i = 1; i < rs->nr; i++) {
- if (rs->ranges[i].start <= rs->ranges[o-1].end) {
+ for (i = 0; i < rs->nr; i++) {
+ if (rs->ranges[i].start == rs->ranges[i].end)
+ continue;
+ if (o > 0 && rs->ranges[i].start <= rs->ranges[o-1].end) {
if (rs->ranges[o-1].end < rs->ranges[i].end)
rs->ranges[o-1].end = rs->ranges[i].end;
} else {
@@ -297,6 +299,7 @@ static void line_log_data_insert(struct line_log_data **list,
p = xcalloc(1, sizeof(struct line_log_data));
p->path = path;
range_set_append(&p->ranges, begin, end);
+ sort_and_merge_range_set(&p->ranges);
if (ip) {
p->next = ip->next;
ip->next = p;