Move function filter_object to diff.c, like it is done with
function textconv_object.

Signed-off-by: Olga Telezhnaia <[email protected]>
---
 builtin/cat-file.c | 23 -----------------------
 diff.c             | 23 +++++++++++++++++++++++
 diff.h             |  4 ++++
 3 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index cd9a4447c8da9..41f333b73d851 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -3,7 +3,6 @@
  *
  * Copyright (C) Linus Torvalds, 2005
  */
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
@@ -34,28 +33,6 @@ static int mark_query;
 static int skip_object_info;
 static const char *rest;
 
-static int filter_object(const char *path, unsigned mode,
-                        const struct object_id *oid,
-                        char **buf, unsigned long *size)
-{
-       enum object_type type;
-
-       *buf = read_object_file(oid, &type, size);
-       if (!*buf)
-               return error(_("cannot read object %s '%s'"),
-                            oid_to_hex(oid), path);
-       if ((type == OBJ_BLOB) && S_ISREG(mode)) {
-               struct strbuf strbuf = STRBUF_INIT;
-               if (convert_to_working_tree(&the_index, path, *buf, *size, 
&strbuf)) {
-                       free(*buf);
-                       *size = strbuf.len;
-                       *buf = strbuf_detach(&strbuf, NULL);
-               }
-       }
-
-       return 0;
-}
-
 static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
                        int unknown_type)
 {
diff --git a/diff.c b/diff.c
index 5306c48652db5..fe7160c86755d 100644
--- a/diff.c
+++ b/diff.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2005 Junio C Hamano
  */
+#define USE_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "config.h"
 #include "tempfile.h"
@@ -6524,6 +6525,28 @@ int textconv_object(struct repository *r,
        return 1;
 }
 
+int filter_object(const char *path, unsigned mode,
+                 const struct object_id *oid,
+                 char **buf, unsigned long *size)
+{
+       enum object_type type;
+
+       *buf = read_object_file(oid, &type, size);
+       if (!*buf)
+               return error(_("cannot read object %s '%s'"),
+                            oid_to_hex(oid), path);
+       if ((type == OBJ_BLOB) && S_ISREG(mode)) {
+               struct strbuf strbuf = STRBUF_INIT;
+               if (convert_to_working_tree(&the_index, path, *buf, *size, 
&strbuf)) {
+                       free(*buf);
+                       *size = strbuf.len;
+                       *buf = strbuf_detach(&strbuf, NULL);
+               }
+       }
+
+       return 0;
+}
+
 void setup_diff_pager(struct diff_options *opt)
 {
        /*
diff --git a/diff.h b/diff.h
index b512d0477ac3a..c3709e611870a 100644
--- a/diff.h
+++ b/diff.h
@@ -476,6 +476,10 @@ int textconv_object(struct repository *repo,
                    const struct object_id *oid, int oid_valid,
                    char **buf, unsigned long *buf_size);
 
+int filter_object(const char *path, unsigned mode,
+                 const struct object_id *oid,
+                 char **buf, unsigned long *size);
+
 int parse_rename_score(const char **cp_p);
 
 long parse_algorithm_value(const char *value);

--
https://github.com/git/git/pull/568

Reply via email to