Skip to content

Commit c876d6d

Browse files
peffgitster
authored andcommitted
grep: drop grep_buffer's "name" parameter
Before the grep_source interface existed, grep_buffer was used by two types of callers: 1. Ones which pulled a file into a buffer, and then wanted to supply the file's name for the output (i.e., git grep). 2. Ones which really just wanted to grep a buffer (i.e., git log --grep). Callers in set (1) should now be using grep_source. Callers in set (2) always pass NULL for the "name" parameter of grep_buffer. We can therefore get rid of this now-useless parameter. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8f24a63 commit c876d6d

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

grep.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,12 +1215,12 @@ int grep_source(struct grep_opt *opt, struct grep_source *gs)
12151215
return grep_source_1(opt, gs, 0);
12161216
}
12171217

1218-
int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size)
1218+
int grep_buffer(struct grep_opt *opt, char *buf, unsigned long size)
12191219
{
12201220
struct grep_source gs;
12211221
int r;
12221222

1223-
grep_source_init(&gs, GREP_SOURCE_BUF, name, NULL);
1223+
grep_source_init(&gs, GREP_SOURCE_BUF, NULL, NULL);
12241224
gs.buf = buf;
12251225
gs.size = size;
12261226

grep.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const cha
127127
extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
128128
extern void compile_grep_patterns(struct grep_opt *opt);
129129
extern void free_grep_patterns(struct grep_opt *opt);
130-
extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
130+
extern int grep_buffer(struct grep_opt *opt, char *buf, unsigned long size);
131131

132132
struct grep_source {
133133
char *name;

revision.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2128,7 +2128,6 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
21282128
if (!opt->grep_filter.pattern_list && !opt->grep_filter.header_list)
21292129
return 1;
21302130
return grep_buffer(&opt->grep_filter,
2131-
NULL, /* we say nothing, not even filename */
21322131
commit->buffer, strlen(commit->buffer));
21332132
}
21342133

0 commit comments

Comments
 (0)