Skip to content

Commit 2c048a3

Browse files
chriscoolgitster
authored andcommitted
revert: fix off by one read when searching the end of a commit subject
A test case is added but the problem can only be seen when running the test case with --valgrind. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Acked-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 971ecbd commit 2c048a3

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

builtin/revert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static int get_message(const char *raw_message, struct commit_message *out)
127127
p++;
128128
if (*p) {
129129
p += 2;
130-
for (eol = p + 1; *eol && *eol != '\n'; eol++)
130+
for (eol = p; *eol && *eol != '\n'; eol++)
131131
; /* do nothing */
132132
} else
133133
eol = p;

t/t3505-cherry-pick-empty.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,29 @@ test_expect_success setup '
1313
1414
git checkout -b empty-branch &&
1515
test_tick &&
16-
git commit --allow-empty -m "empty"
16+
git commit --allow-empty -m "empty" &&
17+
18+
echo third >> file1 &&
19+
git add file1 &&
20+
test_tick &&
21+
git commit --allow-empty-message -m ""
1722
1823
'
1924

2025
test_expect_success 'cherry-pick an empty commit' '
26+
git checkout master && {
27+
git cherry-pick empty-branch^
28+
test "$?" = 1
29+
}
30+
'
31+
32+
test_expect_success 'index lockfile was removed' '
33+
34+
test ! -f .git/index.lock
35+
36+
'
37+
38+
test_expect_success 'cherry-pick a commit with an empty message' '
2139
git checkout master && {
2240
git cherry-pick empty-branch
2341
test "$?" = 1

0 commit comments

Comments
 (0)