aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-03-21 14:55:12 -0700
committerJunio C Hamano <gitster@pobox.com>2024-03-21 14:55:12 -0700
commit8be51c1f36e7891c2d9c934d9bb8a81970a0f04e (patch)
tree0b4d7efe5ba99b7a0c6d1d29816dfb48bb717534
parent3eba921f813641cdac96532c5c4fd99358a8cbb8 (diff)
parent2541cba2d6808011be84469a3e700d0d59a1d612 (diff)
downloadgit-8be51c1f36e7891c2d9c934d9bb8a81970a0f04e.tar.gz
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
-rwxr-xr-xt/t7513-interpret-trailers.sh14
-rw-r--r--wt-status.c7
2 files changed, 19 insertions, 2 deletions
diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh
index ec9c6de114..3d3e13ccf8 100755
--- a/t/t7513-interpret-trailers.sh
+++ b/t/t7513-interpret-trailers.sh
@@ -1935,4 +1935,18 @@ test_expect_success 'suppressing --- does not disable cut-line handling' '
test_cmp expected actual
'
+test_expect_success 'handling of --- lines in conjunction with cut-lines' '
+ echo "my-trailer: here" >expected &&
+
+ git interpret-trailers --parse >actual <<-\EOF &&
+ subject
+
+ my-trailer: here
+ ---
+ # ------------------------ >8 ------------------------
+ EOF
+
+ test_cmp expected actual
+'
+
test_done
diff --git a/wt-status.c b/wt-status.c
index 7108a92b52..2db4bb3a12 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1093,8 +1093,11 @@ size_t wt_status_locate_end(const char *s, size_t len)
strbuf_addf(&pattern, "\n%c %s", comment_line_char, cut_line);
if (starts_with(s, pattern.buf + 1))
len = 0;
- else if ((p = strstr(s, pattern.buf)))
- len = p - s + 1;
+ else if ((p = strstr(s, pattern.buf))) {
+ size_t newlen = p - s + 1;
+ if (newlen < len)
+ len = newlen;
+ }
strbuf_release(&pattern);
return len;
}