--- v1
+++ v3
@@ -8,9 +8,9 @@
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
---
builtin/grep.c | 4 ++--
- grep.c | 43 +++++++++++++++++++++++++++----------------
- grep.h | 8 +++++---
- 3 files changed, 34 insertions(+), 21 deletions(-)
+ grep.c | 46 ++++++++++++++++++++++++++++------------------
+ grep.h | 7 ++++---
+ 3 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/builtin/grep.c b/builtin/grep.c
index 87bcb934a2..e454335e9d 100644
@@ -35,19 +35,38 @@
if (num_threads > 1) {
diff --git a/grep.c b/grep.c
-index 424a39591b..ba3711dc56 100644
+index 424a39591b..8a8105c2eb 100644
--- a/grep.c
+++ b/grep.c
-@@ -1830,7 +1830,7 @@ int grep_buffer(struct grep_opt *opt, char *buf, unsigned long size)
+@@ -1825,14 +1825,24 @@ int grep_source(struct grep_opt *opt, struct grep_source *gs)
+ return grep_source_1(opt, gs, 0);
+ }
+
++static void grep_source_init_buf(struct grep_source *gs, char *buf,
++ unsigned long size)
++{
++ gs->type = GREP_SOURCE_BUF;
++ gs->name = NULL;
++ gs->path = NULL;
++ gs->buf = buf;
++ gs->size = size;
++ gs->driver = NULL;
++ gs->identifier = NULL;
++}
++
+ int grep_buffer(struct grep_opt *opt, char *buf, unsigned long size)
+ {
struct grep_source gs;
int r;
- grep_source_init(&gs, GREP_SOURCE_BUF, NULL, NULL, NULL);
-+ grep_source_init_buf(&gs);
- gs.buf = buf;
- gs.size = size;
+- gs.buf = buf;
+- gs.size = size;
++ grep_source_init_buf(&gs, buf, size);
-@@ -1840,28 +1840,39 @@ int grep_buffer(struct grep_opt *opt, char *buf, unsigned long size)
+ r = grep_source(opt, &gs);
+
+@@ -1840,28 +1850,28 @@ int grep_buffer(struct grep_opt *opt, char *buf, unsigned long size)
return r;
}
@@ -88,25 +107,14 @@
+ gs->size = 0;
+ gs->driver = NULL;
+ gs->identifier = oiddup(oid);
-+}
-+
-+void grep_source_init_buf(struct grep_source *gs)
-+{
-+ gs->type = GREP_SOURCE_BUF;
-+ gs->name = NULL;
-+ gs->path = NULL;
-+ gs->buf = NULL;
-+ gs->size = 0;
-+ gs->driver = NULL;
-+ gs->identifier = NULL;
}
void grep_source_clear(struct grep_source *gs)
diff --git a/grep.h b/grep.h
-index 72f82b1e30..f4a3090f1c 100644
+index 72f82b1e30..480b3f5bba 100644
--- a/grep.h
+++ b/grep.h
-@@ -195,9 +195,11 @@ struct grep_source {
+@@ -195,9 +195,10 @@ struct grep_source {
struct userdiff_driver *driver;
};
@@ -117,7 +125,6 @@
+ const char *path);
+void grep_source_init_oid(struct grep_source *gs, const char *name,
+ const char *path, const struct object_id *oid);
-+void grep_source_init_buf(struct grep_source *gs);
void grep_source_clear_data(struct grep_source *gs);
void grep_source_clear(struct grep_source *gs);
void grep_source_load_driver(struct grep_source *gs,