sha1_file: convert index_fd to struct object_id
authorPatryk Obara <patryk.obara@gmail.com>
Sun, 20 Aug 2017 20:09:29 +0000 (22:09 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Aug 2017 04:52:08 +0000 (21:52 -0700)
Convert all remaining callers as well.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/difftool.c
builtin/hash-object.c
builtin/replace.c
cache.h
read-cache.c
sha1_file.c
index 8864d846f89846669a5403d3a9436aa784d47be2..b2d3ba7539d5b9cdc7ec6f910ee24510e709f76c 100644 (file)
@@ -111,7 +111,7 @@ static int use_wt_file(const char *workdir, const char *name,
                int fd = open(buf.buf, O_RDONLY);
 
                if (fd >= 0 &&
-                   !index_fd(wt_oid.hash, fd, &st, OBJ_BLOB, name, 0)) {
+                   !index_fd(&wt_oid, fd, &st, OBJ_BLOB, name, 0)) {
                        if (is_null_oid(oid)) {
                                oidcpy(oid, &wt_oid);
                                use = 1;
index 1c0f0f332796f00bbd2705c0eb67aeab2be3809b..8a58ce085a80d2c9aa38763d97112589f50fa237 100644 (file)
@@ -38,7 +38,7 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
        if (fstat(fd, &st) < 0 ||
            (literally
             ? hash_literally(&oid, fd, type, flags)
-            : index_fd(oid.hash, fd, &st, type_from_string(type), path, flags)))
+            : index_fd(&oid, fd, &st, type_from_string(type), path, flags)))
                die((flags & HASH_WRITE_OBJECT)
                    ? "Unable to add %s to database"
                    : "Unable to hash %s", path);
index f4a85a165bbff187f331a0a4675066fc5f7b4316..3e71a771523d8566590bfbd5de71b08acf79e3a4 100644 (file)
@@ -269,7 +269,7 @@ static void import_object(struct object_id *oid, enum object_type type,
 
                if (fstat(fd, &st) < 0)
                        die_errno("unable to fstat %s", filename);
-               if (index_fd(oid->hash, fd, &st, type, NULL, flags) < 0)
+               if (index_fd(oid, fd, &st, type, NULL, flags) < 0)
                        die("unable to write object to database");
                /* index_fd close()s fd for us */
        }
diff --git a/cache.h b/cache.h
index 380868ddb2ec0935b0eed41c9799e0263ac934f9..eaf3603777ec01e0c69de47335ed6cf534065414 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -684,7 +684,7 @@ extern int ie_modified(const struct index_state *, const struct cache_entry *, s
 
 #define HASH_WRITE_OBJECT 1
 #define HASH_FORMAT_CHECK 2
-extern int index_fd(unsigned char *sha1, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
+extern int index_fd(struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
 extern int index_path(struct object_id *oid, const char *path, struct stat *st, unsigned flags);
 
 /*
index 17f19a11ff40b425ba8aa73d6dc64a9d47fef300..9b4105856992859f3a1d7f4462843196aacdc484 100644 (file)
@@ -161,7 +161,7 @@ static int ce_compare_data(const struct cache_entry *ce, struct stat *st)
 
        if (fd >= 0) {
                struct object_id oid;
-               if (!index_fd(oid.hash, fd, st, OBJ_BLOB, ce->name, 0))
+               if (!index_fd(&oid, fd, st, OBJ_BLOB, ce->name, 0))
                        match = oidcmp(&oid, &ce->oid);
                /* index_fd() closed the file descriptor already */
        }
index 6a2a48ba2063cb97cf96ea68d89d1296baae16a3..132b25bd7421bfb7b6e0ba04b451e3e04d832ace 100644 (file)
@@ -3662,7 +3662,7 @@ static int index_stream(unsigned char *sha1, int fd, size_t size,
        return index_bulk_checkin(sha1, fd, size, type, path, flags);
 }
 
-int index_fd(unsigned char *sha1, int fd, struct stat *st,
+int index_fd(struct object_id *oid, int fd, struct stat *st,
             enum object_type type, const char *path, unsigned flags)
 {
        int ret;
@@ -3672,15 +3672,15 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st,
         * die() for large files.
         */
        if (type == OBJ_BLOB && path && would_convert_to_git_filter_fd(path))
-               ret = index_stream_convert_blob(sha1, fd, path, flags);
+               ret = index_stream_convert_blob(oid->hash, fd, path, flags);
        else if (!S_ISREG(st->st_mode))
-               ret = index_pipe(sha1, fd, type, path, flags);
+               ret = index_pipe(oid->hash, fd, type, path, flags);
        else if (st->st_size <= big_file_threshold || type != OBJ_BLOB ||
                 (path && would_convert_to_git(&the_index, path)))
-               ret = index_core(sha1, fd, xsize_t(st->st_size), type, path,
+               ret = index_core(oid->hash, fd, xsize_t(st->st_size), type, path,
                                 flags);
        else
-               ret = index_stream(sha1, fd, xsize_t(st->st_size), type, path,
+               ret = index_stream(oid->hash, fd, xsize_t(st->st_size), type, path,
                                   flags);
        close(fd);
        return ret;
@@ -3696,7 +3696,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
                fd = open(path, O_RDONLY);
                if (fd < 0)
                        return error_errno("open(\"%s\")", path);
-               if (index_fd(oid->hash, fd, st, OBJ_BLOB, path, flags) < 0)
+               if (index_fd(oid, fd, st, OBJ_BLOB, path, flags) < 0)
                        return error("%s: failed to insert into database",
                                     path);
                break;