Merge branch 'sg/commit-cleanup-scissors' into maint
"git commit --cleanup=scissors" was not careful enough to protect against getting fooled by a line that looked like scissors. * sg/commit-cleanup-scissors: commit: cope with scissors lines in commit message
This commit is contained in:
commit
a94594dcf7
@ -229,14 +229,36 @@ test_expect_success 'cleanup commit messages (scissors option,-F,-e)' '
|
|||||||
cat >text <<EOF &&
|
cat >text <<EOF &&
|
||||||
|
|
||||||
# to be kept
|
# to be kept
|
||||||
|
|
||||||
|
# ------------------------ >8 ------------------------
|
||||||
|
# to be kept, too
|
||||||
# ------------------------ >8 ------------------------
|
# ------------------------ >8 ------------------------
|
||||||
to be removed
|
to be removed
|
||||||
|
# ------------------------ >8 ------------------------
|
||||||
|
to be removed, too
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat >expect <<EOF &&
|
||||||
|
# to be kept
|
||||||
|
|
||||||
|
# ------------------------ >8 ------------------------
|
||||||
|
# to be kept, too
|
||||||
EOF
|
EOF
|
||||||
echo "# to be kept" >expect &&
|
|
||||||
git commit --cleanup=scissors -e -F text -a &&
|
git commit --cleanup=scissors -e -F text -a &&
|
||||||
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
|
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'cleanup commit messages (scissors option,-F,-e, scissors on first line)' '
|
||||||
|
|
||||||
|
echo >>negative &&
|
||||||
|
cat >text <<EOF &&
|
||||||
|
# ------------------------ >8 ------------------------
|
||||||
|
to be removed
|
||||||
|
EOF
|
||||||
|
git commit --cleanup=scissors -e -F text -a --allow-empty-message &&
|
||||||
|
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
|
||||||
|
test_must_be_empty actual
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'cleanup commit messages (strip option,-F)' '
|
test_expect_success 'cleanup commit messages (strip option,-F)' '
|
||||||
|
@ -823,10 +823,11 @@ void wt_status_truncate_message_at_cut_line(struct strbuf *buf)
|
|||||||
const char *p;
|
const char *p;
|
||||||
struct strbuf pattern = STRBUF_INIT;
|
struct strbuf pattern = STRBUF_INIT;
|
||||||
|
|
||||||
strbuf_addf(&pattern, "%c %s", comment_line_char, cut_line);
|
strbuf_addf(&pattern, "\n%c %s", comment_line_char, cut_line);
|
||||||
p = strstr(buf->buf, pattern.buf);
|
if (starts_with(buf->buf, pattern.buf + 1))
|
||||||
if (p && (p == buf->buf || p[-1] == '\n'))
|
strbuf_setlen(buf, 0);
|
||||||
strbuf_setlen(buf, p - buf->buf);
|
else if ((p = strstr(buf->buf, pattern.buf)))
|
||||||
|
strbuf_setlen(buf, p - buf->buf + 1);
|
||||||
strbuf_release(&pattern);
|
strbuf_release(&pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user