sha1_file: convert pretend_sha1_file to object_id

Convert the declaration and definition of pretend_sha1_file to use struct object_id and adjust all usages of this function. Rename it to pretend_object_file. Signed-off-by: Patryk Obara <patryk.obara@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patryk Obara committed Jan 28, 2018 at 01:13 UTC 829e5c3b9276a2369452a119faec234276b7ecbb
4 files changed +11 -8
Documentation/technical/api-object-access.txt
+1 -1
@@ -7,7 +7,7 @@ Talk about <sha1_file.c> and <object.h> family, things like
7 * read_object_with_reference()
8 * has_sha1_file()
9 * write_sha1_file()
10 -* pretend_sha1_file()
10 +* pretend_object_file()
11 * lookup_{object,commit,tag,blob,tree}
12 * parse_{object,commit,tag,blob,tree}
13 * Use of object flags
blame.c
+1 -1
@@ -232,7 +232,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
232 convert_to_git(&the_index, path, buf.buf, buf.len, &buf, 0);
233 origin->file.ptr = buf.buf;
234 origin->file.size = buf.len;
235 - pretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_oid.hash);
235 + pretend_object_file(buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);
236
237 /*
238 * Read the current index, replace the path entry with
cache.h
+4 -1
@@ -1241,7 +1241,10 @@ extern int sha1_object_info(const unsigned char *, unsigned long *);
1241 extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);
1242 extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
1243 extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, struct object_id *oid, unsigned flags);
1244 -extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
1244 +
1245 +extern int pretend_object_file(void *, unsigned long, enum object_type,
1246 + struct object_id *oid);
1247 +
1248 extern int force_object_loose(const unsigned char *sha1, time_t mtime);
1249 extern int git_open_cloexec(const char *name, int flags);
1250 #define git_open(name) git_open_cloexec(name, O_RDONLY)
sha1_file.c
+5 -5
@@ -1312,13 +1312,13 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,
1312 return content;
1313 }
1314
1315 -int pretend_sha1_file(void *buf, unsigned long len, enum object_type type,
1316 - unsigned char *sha1)
1315 +int pretend_object_file(void *buf, unsigned long len, enum object_type type,
1316 + struct object_id *oid)
1317 {
1318 struct cached_object *co;
1319
1320 - hash_sha1_file(buf, len, typename(type), sha1);
1321 - if (has_sha1_file(sha1) || find_cached_object(sha1))
1320 + hash_sha1_file(buf, len, typename(type), oid->hash);
1321 + if (has_sha1_file(oid->hash) || find_cached_object(oid->hash))
1322 return 0;
1323 ALLOC_GROW(cached_objects, cached_object_nr + 1, cached_object_alloc);
1324 co = &cached_objects[cached_object_nr++];
@@ -1326,7 +1326,7 @@ int pretend_sha1_file(void *buf, unsigned long len, enum object_type type,
1326 co->type = type;
1327 co->buf = xmalloc(len);
1328 memcpy(co->buf, buf, len);
1329 - hashcpy(co->sha1, sha1);
1329 + hashcpy(co->sha1, oid->hash);
1330 return 0;
1331 }
1332