]> git.ipfire.org Git - thirdparty/git.git/commitdiff
convert: make convert_attrs() and convert structs public
authorJeff Hostetler <jeffhost@microsoft.com>
Wed, 16 Dec 2020 14:50:30 +0000 (11:50 -0300)
committerJunio C Hamano <gitster@pobox.com>
Thu, 18 Mar 2021 20:56:40 +0000 (13:56 -0700)
Move convert_attrs() declaration from convert.c to convert.h, together
with the conv_attrs struct and the crlf_action enum. This function and
the data structures will be used outside convert.c in the upcoming
parallel checkout implementation. Note that crlf_action is renamed to
convert_crlf_action, which is more appropriate for the global namespace.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
convert.c
convert.h

index ee360c2f07ced0daa8f3f7b1b651fae7c245cb26..f13b0012733f5db220096d21613fdff5679bc32a 100644 (file)
--- a/convert.c
+++ b/convert.c
 #define CONVERT_STAT_BITS_TXT_CRLF  0x2
 #define CONVERT_STAT_BITS_BIN       0x4
 
-enum crlf_action {
-       CRLF_UNDEFINED,
-       CRLF_BINARY,
-       CRLF_TEXT,
-       CRLF_TEXT_INPUT,
-       CRLF_TEXT_CRLF,
-       CRLF_AUTO,
-       CRLF_AUTO_INPUT,
-       CRLF_AUTO_CRLF
-};
-
 struct text_stat {
        /* NUL, CR, LF and CRLF counts */
        unsigned nul, lonecr, lonelf, crlf;
@@ -172,7 +161,7 @@ static int text_eol_is_crlf(void)
        return 0;
 }
 
-static enum eol output_eol(enum crlf_action crlf_action)
+static enum eol output_eol(enum convert_crlf_action crlf_action)
 {
        switch (crlf_action) {
        case CRLF_BINARY:
@@ -246,7 +235,7 @@ static int has_crlf_in_index(const struct index_state *istate, const char *path)
 }
 
 static int will_convert_lf_to_crlf(struct text_stat *stats,
-                                  enum crlf_action crlf_action)
+                                  enum convert_crlf_action crlf_action)
 {
        if (output_eol(crlf_action) != EOL_CRLF)
                return 0;
@@ -499,7 +488,7 @@ static int encode_to_worktree(const char *path, const char *src, size_t src_len,
 static int crlf_to_git(const struct index_state *istate,
                       const char *path, const char *src, size_t len,
                       struct strbuf *buf,
-                      enum crlf_action crlf_action, int conv_flags)
+                      enum convert_crlf_action crlf_action, int conv_flags)
 {
        struct text_stat stats;
        char *dst;
@@ -585,8 +574,8 @@ static int crlf_to_git(const struct index_state *istate,
        return 1;
 }
 
-static int crlf_to_worktree(const char *src, size_t len,
-                           struct strbuf *buf, enum crlf_action crlf_action)
+static int crlf_to_worktree(const char *src, size_t len, struct strbuf *buf,
+                           enum convert_crlf_action crlf_action)
 {
        char *to_free = NULL;
        struct text_stat stats;
@@ -1247,7 +1236,7 @@ static const char *git_path_check_encoding(struct attr_check_item *check)
        return value;
 }
 
-static enum crlf_action git_path_check_crlf(struct attr_check_item *check)
+static enum convert_crlf_action git_path_check_crlf(struct attr_check_item *check)
 {
        const char *value = check->value;
 
@@ -1297,18 +1286,10 @@ static int git_path_check_ident(struct attr_check_item *check)
        return !!ATTR_TRUE(value);
 }
 
-struct conv_attrs {
-       struct convert_driver *drv;
-       enum crlf_action attr_action; /* What attr says */
-       enum crlf_action crlf_action; /* When no attr is set, use core.autocrlf */
-       int ident;
-       const char *working_tree_encoding; /* Supported encoding or default encoding if NULL */
-};
-
 static struct attr_check *check;
 
-static void convert_attrs(const struct index_state *istate,
-                         struct conv_attrs *ca, const char *path)
+void convert_attrs(const struct index_state *istate,
+                  struct conv_attrs *ca, const char *path)
 {
        struct attr_check_item *ccheck = NULL;
 
index e29d1026a6866b63b047b6838727bcb71ea6eccb..5678e99922fd0643e3890d4113f26feff38b4bee 100644 (file)
--- a/convert.h
+++ b/convert.h
@@ -63,6 +63,30 @@ struct checkout_metadata {
        struct object_id blob;
 };
 
+enum convert_crlf_action {
+       CRLF_UNDEFINED,
+       CRLF_BINARY,
+       CRLF_TEXT,
+       CRLF_TEXT_INPUT,
+       CRLF_TEXT_CRLF,
+       CRLF_AUTO,
+       CRLF_AUTO_INPUT,
+       CRLF_AUTO_CRLF
+};
+
+struct convert_driver;
+
+struct conv_attrs {
+       struct convert_driver *drv;
+       enum convert_crlf_action attr_action; /* What attr says */
+       enum convert_crlf_action crlf_action; /* When no attr is set, use core.autocrlf */
+       int ident;
+       const char *working_tree_encoding; /* Supported encoding or default encoding if NULL */
+};
+
+void convert_attrs(const struct index_state *istate,
+                  struct conv_attrs *ca, const char *path);
+
 extern enum eol core_eol;
 extern char *check_roundtrip_encoding;
 const char *get_cached_convert_stats_ascii(const struct index_state *istate,