Skip to content

Commit 829e5c3

Browse files
dreamergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5be1f00 commit 829e5c3

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

Documentation/technical/api-object-access.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Talk about <sha1_file.c> and <object.h> family, things like
77
* read_object_with_reference()
88
* has_sha1_file()
99
* write_sha1_file()
10-
* pretend_sha1_file()
10+
* pretend_object_file()
1111
* lookup_{object,commit,tag,blob,tree}
1212
* parse_{object,commit,tag,blob,tree}
1313
* Use of object flags

blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
232232
convert_to_git(&the_index, path, buf.buf, buf.len, &buf, 0);
233233
origin->file.ptr = buf.buf;
234234
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);
236236

237237
/*
238238
* Read the current index, replace the path entry with

cache.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,10 @@ extern int sha1_object_info(const unsigned char *, unsigned long *);
12411241
extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);
12421242
extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
12431243
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+
12451248
extern int force_object_loose(const unsigned char *sha1, time_t mtime);
12461249
extern int git_open_cloexec(const char *name, int flags);
12471250
#define git_open(name) git_open_cloexec(name, O_RDONLY)

sha1_file.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,21 +1312,21 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,
13121312
return content;
13131313
}
13141314

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)
13171317
{
13181318
struct cached_object *co;
13191319

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))
13221322
return 0;
13231323
ALLOC_GROW(cached_objects, cached_object_nr + 1, cached_object_alloc);
13241324
co = &cached_objects[cached_object_nr++];
13251325
co->size = len;
13261326
co->type = type;
13271327
co->buf = xmalloc(len);
13281328
memcpy(co->buf, buf, len);
1329-
hashcpy(co->sha1, sha1);
1329+
hashcpy(co->sha1, oid->hash);
13301330
return 0;
13311331
}
13321332

0 commit comments

Comments
 (0)