{"thread":{"id":"46634","subject":"[PATCH 0/6] Convert hash-object to struct object_id","startedAt":"2017-08-20T20:09:42Z","lastAt":"2017-08-21T05:00:09Z","messageCount":10,"participants":["Patryk Obara","brian m. carlson","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"326827","messageId":"cover.1503258223.git.patryk.obara@gmail.com","threadId":"46634","inReplyTo":null,"subject":"[PATCH 0/6] Convert hash-object to struct object_id","fromName":"Patryk Obara","fromEmail":"patryk.obara@gmail.com","sentAt":"2017-08-20T20:09:25Z","receivedAt":"2017-08-20T20:09:42Z","isPatch":true,"sender":{"key":"patryk.obara@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3967?v=4"},"body":"This enabled conversion of few functions in sha1_file, which\nhad almost all callers converted already.\n\nI hope I'm not stepping on anyone's toes with this patch series.\nIf I do - is there some email thread or document in which I can\ncoordinate with other developers, regarding which code regions\nare being converted to struct object_id next?\n\nI focused on this builtin in particular because it's probably\nthe smallest functionality, that can be converted to different\nhashing algorithm, at least partly.\n\nPatryk Obara (6):\n  builtin/hash-object: convert to struct object_id\n  read-cache: convert to struct object_id\n  sha1_file: convert index_path to struct object_id\n  sha1_file: convert index_fd to struct object_id\n  sha1_file: convert hash_sha1_file_literally to struct object_id\n  sha1_file: convert index_stream to struct object_id\n\n builtin/difftool.c     |  2 +-\n builtin/hash-object.c  | 12 ++++++------\n builtin/replace.c      |  2 +-\n builtin/update-index.c |  2 +-\n cache.h                |  6 +++---\n diff.c                 |  2 +-\n notes-merge.c          |  2 +-\n read-cache.c           |  8 ++++----\n sha1_file.c            | 34 +++++++++++++++++-----------------\n 9 files changed, 35 insertions(+), 35 deletions(-)\n\n-- \n2.9.5\n\n"},{"id":"326828","messageId":"0eab0c65a0c80f4b367fbf560f51b4dacb556ba9.1503258223.git.patryk.obara@gmail.com","threadId":"46634","inReplyTo":"cover.1503258223.git.patryk.obara@gmail.com","subject":"[PATCH 1/6] builtin/hash-object: convert to struct object_id","fromName":"Patryk Obara","fromEmail":"patryk.obara@gmail.com","sentAt":"2017-08-20T20:09:26Z","receivedAt":"2017-08-20T20:09:43Z","isPatch":true,"sender":{"key":"patryk.obara@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3967?v=4"},"body":"Signed-off-by: Patryk Obara <patryk.obara@gmail.com>\n---\n builtin/hash-object.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex d04baf9..1c0f0f3 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -16,7 +16,7 @@\n  * needs to bypass the data conversion performed by, and the type\n  * limitation imposed by, index_fd() and its callees.\n  */\n-static int hash_literally(unsigned char *sha1, int fd, const char *type, unsigned flags)\n+static int hash_literally(struct object_id *oid, int fd, const char *type, unsigned flags)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tint ret;\n@@ -24,7 +24,7 @@ static int hash_literally(unsigned char *sha1, int fd, const char *type, unsigne\n \tif (strbuf_read(&buf, fd, 4096) < 0)\n \t\tret = -1;\n \telse\n-\t\tret = hash_sha1_file_literally(buf.buf, buf.len, type, sha1, flags);\n+\t\tret = hash_sha1_file_literally(buf.buf, buf.len, type, oid->hash, flags);\n \tstrbuf_release(&buf);\n \treturn ret;\n }\n@@ -33,16 +33,16 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags,\n \t\t    int literally)\n {\n \tstruct stat st;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \n \tif (fstat(fd, &st) < 0 ||\n \t    (literally\n-\t     ? hash_literally(sha1, fd, type, flags)\n-\t     : index_fd(sha1, fd, &st, type_from_string(type), path, flags)))\n+\t     ? hash_literally(&oid, fd, type, flags)\n+\t     : index_fd(oid.hash, fd, &st, type_from_string(type), path, flags)))\n \t\tdie((flags & HASH_WRITE_OBJECT)\n \t\t    ? \"Unable to add %s to database\"\n \t\t    : \"Unable to hash %s\", path);\n-\tprintf(\"%s\\n\", sha1_to_hex(sha1));\n+\tprintf(\"%s\\n\", oid_to_hex(&oid));\n \tmaybe_flush_or_die(stdout, \"hash to stdout\");\n }\n \n-- \n2.9.5\n\n"},{"id":"326829","messageId":"e54161375fa3ff3e292b2bd7bacc6c99a71c88b1.1503258223.git.patryk.obara@gmail.com","threadId":"46634","inReplyTo":"cover.1503258223.git.patryk.obara@gmail.com","subject":"[PATCH 3/6] sha1_file: convert index_path to struct object_id","fromName":"Patryk Obara","fromEmail":"patryk.obara@gmail.com","sentAt":"2017-08-20T20:09:28Z","receivedAt":"2017-08-20T20:09:46Z","isPatch":true,"sender":{"key":"patryk.obara@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3967?v=4"},"body":"Convert all remaining callers as well.\n\nSigned-off-by: Patryk Obara <patryk.obara@gmail.com>\n---\n builtin/update-index.c |  2 +-\n cache.h                |  2 +-\n diff.c                 |  2 +-\n notes-merge.c          |  2 +-\n read-cache.c           |  2 +-\n sha1_file.c            | 10 +++++-----\n 6 files changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 56721cf..d562f2e 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -280,7 +280,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len\n \tfill_stat_cache_info(ce, st);\n \tce->ce_mode = ce_mode_from_stat(old, st->st_mode);\n \n-\tif (index_path(ce->oid.hash, path, st,\n+\tif (index_path(&ce->oid, path, st,\n \t\t       info_only ? 0 : HASH_WRITE_OBJECT)) {\n \t\tfree(ce);\n \t\treturn -1;\ndiff --git a/cache.h b/cache.h\nindex 1c69d2a..380868d 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -685,7 +685,7 @@ extern int ie_modified(const struct index_state *, const struct cache_entry *, s\n #define HASH_WRITE_OBJECT 1\n #define HASH_FORMAT_CHECK 2\n extern int index_fd(unsigned char *sha1, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);\n-extern int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned flags);\n+extern int index_path(struct object_id *oid, const char *path, struct stat *st, unsigned flags);\n \n /*\n  * Record to sd the data from st that we use to check whether a file\ndiff --git a/diff.c b/diff.c\nindex 9c38258..65f8d13 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3246,7 +3246,7 @@ static void diff_fill_oid_info(struct diff_filespec *one)\n \t\t\t}\n \t\t\tif (lstat(one->path, &st) < 0)\n \t\t\t\tdie_errno(\"stat '%s'\", one->path);\n-\t\t\tif (index_path(one->oid.hash, one->path, &st, 0))\n+\t\t\tif (index_path(&one->oid, one->path, &st, 0))\n \t\t\t\tdie(\"cannot hash %s\", one->path);\n \t\t}\n \t}\ndiff --git a/notes-merge.c b/notes-merge.c\nindex c12b354..744c685 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -709,7 +709,7 @@ int notes_merge_commit(struct notes_merge_options *o,\n \t\t/* write file as blob, and add to partial_tree */\n \t\tif (stat(path.buf, &st))\n \t\t\tdie_errno(\"Failed to stat '%s'\", path.buf);\n-\t\tif (index_path(blob_oid.hash, path.buf, &st, HASH_WRITE_OBJECT))\n+\t\tif (index_path(&blob_oid, path.buf, &st, HASH_WRITE_OBJECT))\n \t\t\tdie(\"Failed to write blob object from '%s'\", path.buf);\n \t\tif (add_note(partial_tree, &obj_oid, &blob_oid, NULL))\n \t\t\tdie(\"Failed to add resolved note '%s' to notes tree\",\ndiff --git a/read-cache.c b/read-cache.c\nindex 7285608..17f19a1 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -689,7 +689,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,\n \t\treturn 0;\n \t}\n \tif (!intent_only) {\n-\t\tif (index_path(ce->oid.hash, path, st, HASH_WRITE_OBJECT)) {\n+\t\tif (index_path(&ce->oid, path, st, HASH_WRITE_OBJECT)) {\n \t\t\tfree(ce);\n \t\t\treturn error(\"unable to index file %s\", path);\n \t\t}\ndiff --git a/sha1_file.c b/sha1_file.c\nindex b60ae15..6a2a48b 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -3686,7 +3686,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st,\n \treturn ret;\n }\n \n-int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned flags)\n+int index_path(struct object_id *oid, const char *path, struct stat *st, unsigned flags)\n {\n \tint fd;\n \tstruct strbuf sb = STRBUF_INIT;\n@@ -3696,7 +3696,7 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned\n \t\tfd = open(path, O_RDONLY);\n \t\tif (fd < 0)\n \t\t\treturn error_errno(\"open(\\\"%s\\\")\", path);\n-\t\tif (index_fd(sha1, fd, st, OBJ_BLOB, path, flags) < 0)\n+\t\tif (index_fd(oid->hash, fd, st, OBJ_BLOB, path, flags) < 0)\n \t\t\treturn error(\"%s: failed to insert into database\",\n \t\t\t\t     path);\n \t\tbreak;\n@@ -3704,14 +3704,14 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned\n \t\tif (strbuf_readlink(&sb, path, st->st_size))\n \t\t\treturn error_errno(\"readlink(\\\"%s\\\")\", path);\n \t\tif (!(flags & HASH_WRITE_OBJECT))\n-\t\t\thash_sha1_file(sb.buf, sb.len, blob_type, sha1);\n-\t\telse if (write_sha1_file(sb.buf, sb.len, blob_type, sha1))\n+\t\t\thash_sha1_file(sb.buf, sb.len, blob_type, oid->hash);\n+\t\telse if (write_sha1_file(sb.buf, sb.len, blob_type, oid->hash))\n \t\t\treturn error(\"%s: failed to insert into database\",\n \t\t\t\t     path);\n \t\tstrbuf_release(&sb);\n \t\tbreak;\n \tcase S_IFDIR:\n-\t\treturn resolve_gitlink_ref(path, \"HEAD\", sha1);\n+\t\treturn resolve_gitlink_ref(path, \"HEAD\", oid->hash);\n \tdefault:\n \t\treturn error(\"%s: unsupported file type\", path);\n \t}\n-- \n2.9.5\n\n"},{"id":"326830","messageId":"e15140dfb7b19a1bcaee23889d62bf05ad6e89be.1503258223.git.patryk.obara@gmail.com","threadId":"46634","inReplyTo":"cover.1503258223.git.patryk.obara@gmail.com","subject":"[PATCH 6/6] sha1_file: convert index_stream to struct object_id","fromName":"Patryk Obara","fromEmail":"patryk.obara@gmail.com","sentAt":"2017-08-20T20:09:31Z","receivedAt":"2017-08-20T20:09:51Z","isPatch":true,"sender":{"key":"patryk.obara@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3967?v=4"},"body":"Signed-off-by: Patryk Obara <patryk.obara@gmail.com>\n---\n sha1_file.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 3e2ef4e..8d6960a 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -3655,11 +3655,11 @@ static int index_core(unsigned char *sha1, int fd, size_t size,\n  * binary blobs, they generally do not want to get any conversion, and\n  * callers should avoid this code path when filters are requested.\n  */\n-static int index_stream(unsigned char *sha1, int fd, size_t size,\n+static int index_stream(struct object_id *oid, int fd, size_t size,\n \t\t\tenum object_type type, const char *path,\n \t\t\tunsigned flags)\n {\n-\treturn index_bulk_checkin(sha1, fd, size, type, path, flags);\n+\treturn index_bulk_checkin(oid->hash, fd, size, type, path, flags);\n }\n \n int index_fd(struct object_id *oid, int fd, struct stat *st,\n@@ -3680,7 +3680,7 @@ int index_fd(struct object_id *oid, int fd, struct stat *st,\n \t\tret = index_core(oid->hash, fd, xsize_t(st->st_size), type, path,\n \t\t\t\t flags);\n \telse\n-\t\tret = index_stream(oid->hash, fd, xsize_t(st->st_size), type, path,\n+\t\tret = index_stream(oid, fd, xsize_t(st->st_size), type, path,\n \t\t\t\t   flags);\n \tclose(fd);\n \treturn ret;\n-- \n2.9.5\n\n"},{"id":"326831","messageId":"0cbcf737983cd0a76269010f6a9028a03c8cac1d.1503258223.git.patryk.obara@gmail.com","threadId":"46634","inReplyTo":"cover.1503258223.git.patryk.obara@gmail.com","subject":"[PATCH 5/6] sha1_file: convert hash_sha1_file_literally to struct object_id","fromName":"Patryk Obara","fromEmail":"patryk.obara@gmail.com","sentAt":"2017-08-20T20:09:30Z","receivedAt":"2017-08-20T20:09:54Z","isPatch":true,"sender":{"key":"patryk.obara@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3967?v=4"},"body":"Convert all remaining callers as well.\n\nSigned-off-by: Patryk Obara <patryk.obara@gmail.com>\n---\n builtin/hash-object.c | 2 +-\n cache.h               | 2 +-\n sha1_file.c           | 8 ++++----\n 3 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex 8a58ce0..c532ff9 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -24,7 +24,7 @@ static int hash_literally(struct object_id *oid, int fd, const char *type, unsig\n \tif (strbuf_read(&buf, fd, 4096) < 0)\n \t\tret = -1;\n \telse\n-\t\tret = hash_sha1_file_literally(buf.buf, buf.len, type, oid->hash, flags);\n+\t\tret = hash_sha1_file_literally(buf.buf, buf.len, type, oid, flags);\n \tstrbuf_release(&buf);\n \treturn ret;\n }\ndiff --git a/cache.h b/cache.h\nindex eaf3603..237adb5 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1199,7 +1199,7 @@ static inline const unsigned char *lookup_replace_object(const unsigned char *sh\n extern int sha1_object_info(const unsigned char *, unsigned long *);\n extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);\n extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);\n-extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, unsigned char *sha1, unsigned flags);\n+extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, struct object_id *oid, unsigned flags);\n extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);\n extern int force_object_loose(const unsigned char *sha1, time_t mtime);\n extern int git_open_cloexec(const char *name, int flags);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 11995e5..3e2ef4e 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -3437,7 +3437,7 @@ int write_sha1_file(const void *buf, unsigned long len, const char *type, unsign\n }\n \n int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type,\n-\t\t\t     unsigned char *sha1, unsigned flags)\n+                             struct object_id *oid, unsigned flags)\n {\n \tchar *header;\n \tint hdrlen, status = 0;\n@@ -3445,13 +3445,13 @@ int hash_sha1_file_literally(const void *buf, unsigned long len, const char *typ\n \t/* type string, SP, %lu of the length plus NUL must fit this */\n \thdrlen = strlen(type) + 32;\n \theader = xmalloc(hdrlen);\n-\twrite_sha1_file_prepare(buf, len, type, sha1, header, &hdrlen);\n+\twrite_sha1_file_prepare(buf, len, type, oid->hash, header, &hdrlen);\n \n \tif (!(flags & HASH_WRITE_OBJECT))\n \t\tgoto cleanup;\n-\tif (freshen_packed_object(sha1) || freshen_loose_object(sha1))\n+\tif (freshen_packed_object(oid->hash) || freshen_loose_object(oid->hash))\n \t\tgoto cleanup;\n-\tstatus = write_loose_object(sha1, header, hdrlen, buf, len, 0);\n+\tstatus = write_loose_object(oid->hash, header, hdrlen, buf, len, 0);\n \n cleanup:\n \tfree(header);\n-- \n2.9.5\n\n"},{"id":"326832","messageId":"27ec6a8d1b6fc49cadf7f9e7fed2c2605e02f626.1503258223.git.patryk.obara@gmail.com","threadId":"46634","inReplyTo":"cover.1503258223.git.patryk.obara@gmail.com","subject":"[PATCH 2/6] read-cache: convert to struct object_id","fromName":"Patryk Obara","fromEmail":"patryk.obara@gmail.com","sentAt":"2017-08-20T20:09:27Z","receivedAt":"2017-08-20T20:09:57Z","isPatch":true,"sender":{"key":"patryk.obara@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3967?v=4"},"body":"Replace hashcmp with oidcmp.\n\nSigned-off-by: Patryk Obara <patryk.obara@gmail.com>\n---\n read-cache.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex acfb028..7285608 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -160,9 +160,9 @@ static int ce_compare_data(const struct cache_entry *ce, struct stat *st)\n \tint fd = git_open_cloexec(ce->name, O_RDONLY);\n \n \tif (fd >= 0) {\n-\t\tunsigned char sha1[20];\n-\t\tif (!index_fd(sha1, fd, st, OBJ_BLOB, ce->name, 0))\n-\t\t\tmatch = hashcmp(sha1, ce->oid.hash);\n+\t\tstruct object_id oid;\n+\t\tif (!index_fd(oid.hash, fd, st, OBJ_BLOB, ce->name, 0))\n+\t\t\tmatch = oidcmp(&oid, &ce->oid);\n \t\t/* index_fd() closed the file descriptor already */\n \t}\n \treturn match;\n-- \n2.9.5\n\n"},{"id":"326833","messageId":"6e77d1e53ed00ce638944c4b87be9c533daa27c0.1503258223.git.patryk.obara@gmail.com","threadId":"46634","inReplyTo":"cover.1503258223.git.patryk.obara@gmail.com","subject":"[PATCH 4/6] sha1_file: convert index_fd to struct object_id","fromName":"Patryk Obara","fromEmail":"patryk.obara@gmail.com","sentAt":"2017-08-20T20:09:29Z","receivedAt":"2017-08-20T20:10:01Z","isPatch":true,"sender":{"key":"patryk.obara@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3967?v=4"},"body":"Convert all remaining callers as well.\n\nSigned-off-by: Patryk Obara <patryk.obara@gmail.com>\n---\n builtin/difftool.c    |  2 +-\n builtin/hash-object.c |  2 +-\n builtin/replace.c     |  2 +-\n cache.h               |  2 +-\n read-cache.c          |  2 +-\n sha1_file.c           | 14 +++++++-------\n 6 files changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex 8864d84..b2d3ba7 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -111,7 +111,7 @@ static int use_wt_file(const char *workdir, const char *name,\n \t\tint fd = open(buf.buf, O_RDONLY);\n \n \t\tif (fd >= 0 &&\n-\t\t    !index_fd(wt_oid.hash, fd, &st, OBJ_BLOB, name, 0)) {\n+\t\t    !index_fd(&wt_oid, fd, &st, OBJ_BLOB, name, 0)) {\n \t\t\tif (is_null_oid(oid)) {\n \t\t\t\toidcpy(oid, &wt_oid);\n \t\t\t\tuse = 1;\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex 1c0f0f3..8a58ce0 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -38,7 +38,7 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags,\n \tif (fstat(fd, &st) < 0 ||\n \t    (literally\n \t     ? hash_literally(&oid, fd, type, flags)\n-\t     : index_fd(oid.hash, fd, &st, type_from_string(type), path, flags)))\n+\t     : index_fd(&oid, fd, &st, type_from_string(type), path, flags)))\n \t\tdie((flags & HASH_WRITE_OBJECT)\n \t\t    ? \"Unable to add %s to database\"\n \t\t    : \"Unable to hash %s\", path);\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex f4a85a1..3e71a77 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -269,7 +269,7 @@ static void import_object(struct object_id *oid, enum object_type type,\n \n \t\tif (fstat(fd, &st) < 0)\n \t\t\tdie_errno(\"unable to fstat %s\", filename);\n-\t\tif (index_fd(oid->hash, fd, &st, type, NULL, flags) < 0)\n+\t\tif (index_fd(oid, fd, &st, type, NULL, flags) < 0)\n \t\t\tdie(\"unable to write object to database\");\n \t\t/* index_fd close()s fd for us */\n \t}\ndiff --git a/cache.h b/cache.h\nindex 380868d..eaf3603 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -684,7 +684,7 @@ extern int ie_modified(const struct index_state *, const struct cache_entry *, s\n \n #define HASH_WRITE_OBJECT 1\n #define HASH_FORMAT_CHECK 2\n-extern int index_fd(unsigned char *sha1, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);\n+extern int index_fd(struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);\n extern int index_path(struct object_id *oid, const char *path, struct stat *st, unsigned flags);\n \n /*\ndiff --git a/read-cache.c b/read-cache.c\nindex 17f19a1..9b41058 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -161,7 +161,7 @@ static int ce_compare_data(const struct cache_entry *ce, struct stat *st)\n \n \tif (fd >= 0) {\n \t\tstruct object_id oid;\n-\t\tif (!index_fd(oid.hash, fd, st, OBJ_BLOB, ce->name, 0))\n+\t\tif (!index_fd(&oid, fd, st, OBJ_BLOB, ce->name, 0))\n \t\t\tmatch = oidcmp(&oid, &ce->oid);\n \t\t/* index_fd() closed the file descriptor already */\n \t}\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 6a2a48b..11995e5 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -3662,8 +3662,8 @@ static int index_stream(unsigned char *sha1, int fd, size_t size,\n \treturn index_bulk_checkin(sha1, fd, size, type, path, flags);\n }\n \n-int index_fd(unsigned char *sha1, int fd, struct stat *st,\n-\t     enum object_type type, const char *path, unsigned flags)\n+int index_fd(struct object_id *oid, int fd, struct stat *st,\n+             enum object_type type, const char *path, unsigned flags)\n {\n \tint ret;\n \n@@ -3672,15 +3672,15 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st,\n \t * die() for large files.\n \t */\n \tif (type == OBJ_BLOB && path && would_convert_to_git_filter_fd(path))\n-\t\tret = index_stream_convert_blob(sha1, fd, path, flags);\n+\t\tret = index_stream_convert_blob(oid->hash, fd, path, flags);\n \telse if (!S_ISREG(st->st_mode))\n-\t\tret = index_pipe(sha1, fd, type, path, flags);\n+\t\tret = index_pipe(oid->hash, fd, type, path, flags);\n \telse if (st->st_size <= big_file_threshold || type != OBJ_BLOB ||\n \t\t (path && would_convert_to_git(&the_index, path)))\n-\t\tret = index_core(sha1, fd, xsize_t(st->st_size), type, path,\n+\t\tret = index_core(oid->hash, fd, xsize_t(st->st_size), type, path,\n \t\t\t\t flags);\n \telse\n-\t\tret = index_stream(sha1, fd, xsize_t(st->st_size), type, path,\n+\t\tret = index_stream(oid->hash, fd, xsize_t(st->st_size), type, path,\n \t\t\t\t   flags);\n \tclose(fd);\n \treturn ret;\n@@ -3696,7 +3696,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne\n \t\tfd = open(path, O_RDONLY);\n \t\tif (fd < 0)\n \t\t\treturn error_errno(\"open(\\\"%s\\\")\", path);\n-\t\tif (index_fd(oid->hash, fd, st, OBJ_BLOB, path, flags) < 0)\n+\t\tif (index_fd(oid, fd, st, OBJ_BLOB, path, flags) < 0)\n \t\t\treturn error(\"%s: failed to insert into database\",\n \t\t\t\t     path);\n \t\tbreak;\n-- \n2.9.5\n\n"},{"id":"326834","messageId":"20170820202511.m23njssyika5ufa6@genre.crustytoothpaste.net","threadId":"46634","inReplyTo":"cover.1503258223.git.patryk.obara@gmail.com","subject":"Re: [PATCH 0/6] Convert hash-object to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-08-20T20:25:11Z","receivedAt":"2017-08-20T20:25:24Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Sun, Aug 20, 2017 at 10:09:25PM +0200, Patryk Obara wrote:\n> This enabled conversion of few functions in sha1_file, which\n> had almost all callers converted already.\n> \n> I hope I'm not stepping on anyone's toes with this patch series.\n> If I do - is there some email thread or document in which I can\n> coordinate with other developers, regarding which code regions\n> are being converted to struct object_id next?\n\nWe don't have a coordinated thread at the moment.  You can see what I'm\nworking on at https://github.com/bk2204/git.git in the object-id-part10\nand object-id-part11 branches (based on an older next).\n\nHowever, having said that, I don't mind if you or others pick up various\nparts of the codebase.  At worst, I drop a few patches for things others\nhave already converted.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"326835","messageId":"20170820203705.knec7ggodonh7j7y@genre.crustytoothpaste.net","threadId":"46634","inReplyTo":"0cbcf737983cd0a76269010f6a9028a03c8cac1d.1503258223.git.patryk.obara@gmail.com","subject":"Re: [PATCH 5/6] sha1_file: convert hash_sha1_file_literally to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-08-20T20:37:05Z","receivedAt":"2017-08-20T20:37:14Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Sun, Aug 20, 2017 at 10:09:30PM +0200, Patryk Obara wrote:\n> Convert all remaining callers as well.\n> \n> Signed-off-by: Patryk Obara <patryk.obara@gmail.com>\n> ---\n>  builtin/hash-object.c | 2 +-\n>  cache.h               | 2 +-\n>  sha1_file.c           | 8 ++++----\n>  3 files changed, 6 insertions(+), 6 deletions(-)\n> \n> diff --git a/builtin/hash-object.c b/builtin/hash-object.c\n> index 8a58ce0..c532ff9 100644\n> --- a/builtin/hash-object.c\n> +++ b/builtin/hash-object.c\n> @@ -24,7 +24,7 @@ static int hash_literally(struct object_id *oid, int fd, const char *type, unsig\n>  \tif (strbuf_read(&buf, fd, 4096) < 0)\n>  \t\tret = -1;\n>  \telse\n> -\t\tret = hash_sha1_file_literally(buf.buf, buf.len, type, oid->hash, flags);\n> +\t\tret = hash_sha1_file_literally(buf.buf, buf.len, type, oid, flags);\n>  \tstrbuf_release(&buf);\n>  \treturn ret;\n>  }\n> diff --git a/cache.h b/cache.h\n> index eaf3603..237adb5 100644\n> --- a/cache.h\n> +++ b/cache.h\n> @@ -1199,7 +1199,7 @@ static inline const unsigned char *lookup_replace_object(const unsigned char *sh\n>  extern int sha1_object_info(const unsigned char *, unsigned long *);\n>  extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);\n>  extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);\n> -extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, unsigned char *sha1, unsigned flags);\n> +extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, struct object_id *oid, unsigned flags);\n\nWe probably want to rename this function, since it no longer handles\nexclusively SHA-1.  When I've made changes to the \"_sha1_file\"\nfunctions, I've converted them to \"_object_file\" instead.  However, if\npeople like \"_oid_file\", we could do that instead.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"326850","messageId":"xmqq60dh7bxt.fsf@gitster.mtv.corp.google.com","threadId":"46634","inReplyTo":"20170820202511.m23njssyika5ufa6@genre.crustytoothpaste.net","subject":"Re: [PATCH 0/6] Convert hash-object to struct object_id","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-21T04:59:58Z","receivedAt":"2017-08-21T05:00:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> On Sun, Aug 20, 2017 at 10:09:25PM +0200, Patryk Obara wrote:\n>> This enabled conversion of few functions in sha1_file, which\n>> had almost all callers converted already.\n>> \n>> I hope I'm not stepping on anyone's toes with this patch series.\n>> If I do - is there some email thread or document in which I can\n>> coordinate with other developers, regarding which code regions\n>> are being converted to struct object_id next?\n>\n> We don't have a coordinated thread at the moment.  You can see what I'm\n> working on at https://github.com/bk2204/git.git in the object-id-part10\n> and object-id-part11 branches (based on an older next).\n>\n> However, having said that, I don't mind if you or others pick up various\n> parts of the codebase.  At worst, I drop a few patches for things others\n> have already converted.\n\nThanks for working well together ;-)\n\nI've scanned these patches and they looked OK.  There still are\nplaces that dereferences oid->hash when making a call instead of\npassing a pointer to the whole oid, but that is not making things\nworse.\n\nAs to the naming (your comments on 5/6), I agree that we would need\nto switch s/sha1/oid/ in the names in the endgame.  It may be OK to\nleave it to later rounds when we do use something like your hash\nalgorithm abstraction throughout the codebase.\n\n\n"}]}