Skip to content

Commit 7641eb4

Browse files
committed
Merge branch 'maint'
* maint: GIT 1.6.5.1 grep: do not segfault when -f is used
2 parents c274db7 + b142da2 commit 7641eb4

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed

Documentation/RelNotes-1.6.5.1.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
GIT v1.6.5.1 Release Notes
2+
==========================
3+
4+
Fixes since v1.6.5
5+
------------------
6+
7+
* An corrupt pack could make codepath to read objects into an
8+
infinite loop.
9+
10+
* Download throughput display was always shown in KiB/s but on fast links
11+
it is more appropriate to show it in MiB/s.
12+
13+
* "git grep -f filename" used uninitialized variable and segfaulted.
14+
15+
* "git clone -b branch" gave a wrong commit object name to post-checkout
16+
hook.
17+
18+
* "git pull" over http did not work on msys.
19+
20+
Other minor documentation updates are included.

Documentation/git.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Documentation for older releases are available here:
4646
* link:v1.6.5/git.html[documentation for release 1.6.5]
4747

4848
* release notes for
49+
link:RelNotes-1.6.5.1.txt[1.6.5.1],
4950
link:RelNotes-1.6.5.txt[1.6.5].
5051

5152
* link:v1.6.4.4/git.html[documentation for release 1.6.4.4]

builtin-grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
631631
struct grep_opt *grep_opt = opt->value;
632632
FILE *patterns;
633633
int lno = 0;
634-
struct strbuf sb;
634+
struct strbuf sb = STRBUF_INIT;
635635

636636
patterns = fopen(arg, "r");
637637
if (!patterns)

t/t7002-grep.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,72 @@ test_expect_success 'grep -e A --and --not -e B' '
213213
test_cmp expected actual
214214
'
215215

216+
test_expect_success 'grep -f, non-existent file' '
217+
test_must_fail git grep -f patterns
218+
'
219+
220+
cat >expected <<EOF
221+
file:foo mmap bar
222+
file:foo_mmap bar
223+
file:foo_mmap bar mmap
224+
file:foo mmap bar_mmap
225+
file:foo_mmap bar mmap baz
226+
EOF
227+
228+
cat >pattern <<EOF
229+
mmap
230+
EOF
231+
232+
test_expect_success 'grep -f, one pattern' '
233+
git grep -f pattern >actual &&
234+
test_cmp expected actual
235+
'
236+
237+
cat >expected <<EOF
238+
file:foo mmap bar
239+
file:foo_mmap bar
240+
file:foo_mmap bar mmap
241+
file:foo mmap bar_mmap
242+
file:foo_mmap bar mmap baz
243+
t/a/v:vvv
244+
t/v:vvv
245+
v:vvv
246+
EOF
247+
248+
cat >patterns <<EOF
249+
mmap
250+
vvv
251+
EOF
252+
253+
test_expect_success 'grep -f, multiple patterns' '
254+
git grep -f patterns >actual &&
255+
test_cmp expected actual
256+
'
257+
258+
cat >expected <<EOF
259+
file:foo mmap bar
260+
file:foo_mmap bar
261+
file:foo_mmap bar mmap
262+
file:foo mmap bar_mmap
263+
file:foo_mmap bar mmap baz
264+
t/a/v:vvv
265+
t/v:vvv
266+
v:vvv
267+
EOF
268+
269+
cat >patterns <<EOF
270+
271+
mmap
272+
273+
vvv
274+
275+
EOF
276+
277+
test_expect_success 'grep -f, ignore empty lines' '
278+
git grep -f patterns >actual &&
279+
test_cmp expected actual
280+
'
281+
216282
cat >expected <<EOF
217283
y:y yy
218284
--

0 commit comments

Comments
 (0)