Code

Teach bash completion about recent log long options
[git.git] / convert.c
index 12abdaf2a5ce6ffd1a186b8201fb0a8d3b8d11f1..4b26b1a9b9979c2a7753afdad107c73f3e1aae4c 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -86,7 +86,7 @@ static char *crlf_to_git(const char *path, const char *src, unsigned long *sizep
        unsigned long size, nsize;
        struct text_stat stats;
 
-       if ((action == CRLF_BINARY) || (action == CRLF_GUESS && !auto_crlf))
+       if ((action == CRLF_BINARY) || !auto_crlf)
                return NULL;
 
        size = *sizep;
@@ -154,7 +154,7 @@ static char *crlf_to_worktree(const char *path, const char *src, unsigned long *
        unsigned char last;
 
        if ((action == CRLF_BINARY) || (action == CRLF_INPUT) ||
-           (action == CRLF_GUESS && auto_crlf <= 0))
+           auto_crlf <= 0)
                return NULL;
 
        size = *sizep;
@@ -652,3 +652,18 @@ char *convert_to_working_tree(const char *path, const char *src, unsigned long *
 
        return buf;
 }
+
+void *convert_sha1_file(const char *path, const unsigned char *sha1,
+                        unsigned int mode, enum object_type *type,
+                        unsigned long *size)
+{
+       void *buffer = read_sha1_file(sha1, type, size);
+       if (S_ISREG(mode) && buffer) {
+               void *converted = convert_to_working_tree(path, buffer, size);
+               if (converted) {
+                       free(buffer);
+                       buffer = converted;
+               }
+       }
+       return buffer;
+}