1. Stefan Saasen
  2. git


Junio C Hamano  committed 3e73cb2 Merge

Merge branch 'maint-1.6.0' into maint-1.6.1

* maint-1.6.0:
grep: fix segfault when "git grep '('" is given
Documentation: fix a grammatical error in api-builtin.txt
builtin-merge: fix a typo in an error message

  • Participants
  • Parent commits cc13719, c922b01
  • Branches master

Comments (0)

Files changed (4)

File Documentation/technical/api-builtin.txt

View file
  • Ignore whitespace
 	Make sure there is a work tree, i.e. the command cannot act
 	on bare repositories.
-	This makes only sense when `RUN_SETUP` is also set.
+	This only makes sense when `RUN_SETUP` is also set.
 . Add `builtin-foo.o` to `BUILTIN_OBJS` in `Makefile`.

File builtin-merge.c

View file
  • Ignore whitespace
 	fp = fopen(git_path("MERGE_MSG"), "a");
 	if (!fp)
-		die("Could open %s for writing", git_path("MERGE_MSG"));
+		die("Could not open %s for writing", git_path("MERGE_MSG"));
 	fprintf(fp, "\nConflicts:\n");
 	for (pos = 0; pos < active_nr; pos++) {
 		struct cache_entry *ce = active_cache[pos];

File grep.c

View file
  • Ignore whitespace
 	struct grep_expr *x;
 	p = *list;
+	if (!p)
+		return NULL;
 	switch (p->token) {
 	case GREP_PATTERN: /* atom */
 		*list = p->next;
 		x = compile_pattern_or(list);
-		if (!x)
-			return NULL;
 		if (!*list || (*list)->token != GREP_CLOSE_PAREN)
 			die("unmatched parenthesis");
 		*list = (*list)->next;
 	struct grep_expr *x;
 	p = *list;
+	if (!p)
+		return NULL;
 	switch (p->token) {
 	case GREP_NOT:
 		if (!p->next)
 	int h = 0;
+	if (!x)
+		die("Not a valid grep expression");
 	switch (x->node) {
 		h = match_one_pattern(o, x->u.atom, bol, eol, ctx);

File t/t7002-grep.sh

View file
  • Ignore whitespace
 	git commit -m initial
+test_expect_success 'grep should not segfault with a bad input' '
+	test_must_fail git grep "("
 for H in HEAD ''
 	case "$H" in