blame: move textconv_object with related functions
authorJeff Smith <whydoubt@gmail.com>
Wed, 24 May 2017 05:15:10 +0000 (00:15 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 May 2017 06:41:50 +0000 (15:41 +0900)
textconv_object is used in places other than blame.c and should be moved
to a more appropriate location. Other textconv related functions are
located in diff.c so that seems as good a place as any.

Signed-off-by: Jeff Smith <whydoubt@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin.h
builtin/blame.c
builtin/cat-file.c
diff.c
diff.h
index 9e4a89816d5fbde0ed0b3bebff8f90f70dd4480d..498ac80d07bc5b00a9c66e9e62449d7700bc7550 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -25,8 +25,6 @@ struct fmt_merge_msg_opts {
 extern int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
                         struct fmt_merge_msg_opts *);
 
-extern int textconv_object(const char *path, unsigned mode, const struct object_id *oid, int oid_valid, char **buf, unsigned long *buf_size);
-
 extern int is_builtin(const char *s);
 
 extern int cmd_add(int argc, const char **argv, const char *prefix);
index d39f6af1a922d3ea78b8d1aff9cb6f3611d10fb0..fbd757e58368dd76a1adeb00341b2eb7a9e66efc 100644 (file)
@@ -146,34 +146,6 @@ static int diff_hunks(mmfile_t *file_a, mmfile_t *file_b,
        return xdi_diff(file_a, file_b, &xpp, &xecfg, &ecb);
 }
 
-/*
- * Prepare diff_filespec and convert it using diff textconv API
- * if the textconv driver exists.
- * Return 1 if the conversion succeeds, 0 otherwise.
- */
-int textconv_object(const char *path,
-                   unsigned mode,
-                   const struct object_id *oid,
-                   int oid_valid,
-                   char **buf,
-                   unsigned long *buf_size)
-{
-       struct diff_filespec *df;
-       struct userdiff_driver *textconv;
-
-       df = alloc_filespec(path);
-       fill_filespec(df, oid->hash, oid_valid, mode);
-       textconv = get_textconv(df);
-       if (!textconv) {
-               free_filespec(df);
-               return 0;
-       }
-
-       *buf_size = fill_textconv(textconv, df, buf);
-       free_filespec(df);
-       return 1;
-}
-
 /*
  * Given an origin, prepare mmfile_t structure to be used by the
  * diff machinery
index 1890d7a6390dcae719af33ce5cb59e74832a80e8..79a2c82c56acfd57000c44d08eab79e568cf0841 100644 (file)
@@ -5,6 +5,7 @@
  */
 #include "cache.h"
 #include "builtin.h"
+#include "diff.h"
 #include "parse-options.h"
 #include "userdiff.h"
 #include "streaming.h"
diff --git a/diff.c b/diff.c
index 74283d9001fbc48d11ba5c449ea7c16692791c88..040fb2567c6f5330e1686e613f7914f84f6e1427 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -5270,6 +5270,29 @@ size_t fill_textconv(struct userdiff_driver *driver,
        return size;
 }
 
+int textconv_object(const char *path,
+                   unsigned mode,
+                   const struct object_id *oid,
+                   int oid_valid,
+                   char **buf,
+                   unsigned long *buf_size)
+{
+       struct diff_filespec *df;
+       struct userdiff_driver *textconv;
+
+       df = alloc_filespec(path);
+       fill_filespec(df, oid->hash, oid_valid, mode);
+       textconv = get_textconv(df);
+       if (!textconv) {
+               free_filespec(df);
+               return 0;
+       }
+
+       *buf_size = fill_textconv(textconv, df, buf);
+       free_filespec(df);
+       return 1;
+}
+
 void setup_diff_pager(struct diff_options *opt)
 {
        /*
diff --git a/diff.h b/diff.h
index 5be1ee77a759f330db4ace64a5772f23e3d19d50..52ebd54d9ec5d9346bd0e9868e699782cc30a2ac 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -385,6 +385,13 @@ extern size_t fill_textconv(struct userdiff_driver *driver,
  */
 extern struct userdiff_driver *get_textconv(struct diff_filespec *one);
 
+/*
+ * Prepare diff_filespec and convert it using diff textconv API
+ * if the textconv driver exists.
+ * Return 1 if the conversion succeeds, 0 otherwise.
+ */
+extern int textconv_object(const char *path, unsigned mode, const struct object_id *oid, int oid_valid, char **buf, unsigned long *buf_size);
+
 extern int parse_rename_score(const char **cp_p);
 
 extern long parse_algorithm_value(const char *value);