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>
Christian Couder committed
Jul 22, 2010 at 15:18 UTC
2c048a3038fd4d94e150fbc1dfd2242325ca7db6
2 files changed
+20
-2
builtin/revert.c
+1
-1
@@ -127,7 +127,7 @@ static int get_message(const char *raw_message, struct commit_message *out)
127
p++;
128
if (*p) {
129
p += 2;
130
- for (eol = p + 1; *eol && *eol != '\n'; eol++)
130
+ for (eol = p; *eol && *eol != '\n'; eol++)
131
; /* do nothing */
132
} else
133
eol = p;
t/t3505-cherry-pick-empty.sh
+19
-1
@@ -13,11 +13,29 @@ test_expect_success setup '
13
14
git checkout -b empty-branch &&
15
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 ""
22
23
'
24
25
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' '
39
git checkout master && {
40
git cherry-pick empty-branch
41
test "$?" = 1