cherry-pick: Bug fix 'cherry picked from' message.
[gitweb.git] / sha1_file.c
index 38ccf1b80911facf8e28968306d4cafcc4464229..6d0a72ed093d353a672129f7e460d0c1015212d7 100644 (file)
@@ -2054,7 +2054,7 @@ int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)
 }
 
 int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
-            enum object_type type)
+            enum object_type type, const char *path)
 {
        unsigned long size = st->st_size;
        void *buf;
@@ -2071,10 +2071,10 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
        /*
         * Convert blobs to git internal format
         */
-       if (type == OBJ_BLOB) {
+       if ((type == OBJ_BLOB) && S_ISREG(st->st_mode)) {
                unsigned long nsize = size;
                char *nbuf = buf;
-               if (convert_to_git(NULL, &nbuf, &nsize)) {
+               if (convert_to_git(path, &nbuf, &nsize)) {
                        if (size)
                                munmap(buf, size);
                        size = nsize;
@@ -2107,7 +2107,7 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write
                if (fd < 0)
                        return error("open(\"%s\"): %s", path,
                                     strerror(errno));
-               if (index_fd(sha1, fd, st, write_object, OBJ_BLOB) < 0)
+               if (index_fd(sha1, fd, st, write_object, OBJ_BLOB, path) < 0)
                        return error("%s: failed to insert into database",
                                     path);
                break;