Skip to content

Commit 8be51c1

Browse files
committed
Merge branch 'fs/find-end-of-log-message-fix'
The code to find the effective end of log message can fall into an endless loop, which has been corrected. * fs/find-end-of-log-message-fix: wt-status: don't find scissors line beyond buf len
2 parents 3eba921 + 2541cba commit 8be51c1

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

t/t7513-interpret-trailers.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,4 +1935,18 @@ test_expect_success 'suppressing --- does not disable cut-line handling' '
19351935
test_cmp expected actual
19361936
'
19371937

1938+
test_expect_success 'handling of --- lines in conjunction with cut-lines' '
1939+
echo "my-trailer: here" >expected &&
1940+
1941+
git interpret-trailers --parse >actual <<-\EOF &&
1942+
subject
1943+
1944+
my-trailer: here
1945+
---
1946+
# ------------------------ >8 ------------------------
1947+
EOF
1948+
1949+
test_cmp expected actual
1950+
'
1951+
19381952
test_done

wt-status.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,11 @@ size_t wt_status_locate_end(const char *s, size_t len)
10931093
strbuf_addf(&pattern, "\n%c %s", comment_line_char, cut_line);
10941094
if (starts_with(s, pattern.buf + 1))
10951095
len = 0;
1096-
else if ((p = strstr(s, pattern.buf)))
1097-
len = p - s + 1;
1096+
else if ((p = strstr(s, pattern.buf))) {
1097+
size_t newlen = p - s + 1;
1098+
if (newlen < len)
1099+
len = newlen;
1100+
}
10981101
strbuf_release(&pattern);
10991102
return len;
11001103
}

0 commit comments

Comments
 (0)