Skip to content

Commit 0ff7b4f

Browse files
avargitster
authored andcommitted
object API: rename hash_object_file_literally() to write_*()
Before 0c3db67 (hash-object --literally: fix buffer overrun with extra-long object type, 2015-05-04) the hash-object code being changed here called write_sha1_file() to both hash and write a loose object. Before that we'd use hash_sha1_file() to if "-w" wasn't provided, and otherwise call write_sha1_file(). Now we'll always call the same function for both writing. Let's rename it from hash_*_literally() to write_*_literally(). Even though the write_*() might not actually write if HASH_WRITE_OBJECT isn't in "flags", having it be more similar to write_object_file_flags() than hash_object_file(), but carrying a name that would suggest that it's a variant of the latter is confusing. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0f156db commit 0ff7b4f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

builtin/hash-object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static int hash_literally(struct object_id *oid, int fd, const char *type, unsig
2525
if (strbuf_read(&buf, fd, 4096) < 0)
2626
ret = -1;
2727
else
28-
ret = hash_object_file_literally(buf.buf, buf.len, type, oid,
28+
ret = write_object_file_literally(buf.buf, buf.len, type, oid,
2929
flags);
3030
strbuf_release(&buf);
3131
return ret;

object-file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,9 +2027,9 @@ int write_object_file_flags(const void *buf, unsigned long len,
20272027
return write_loose_object(oid, hdr, hdrlen, buf, len, 0, flags);
20282028
}
20292029

2030-
int hash_object_file_literally(const void *buf, unsigned long len,
2031-
const char *type, struct object_id *oid,
2032-
unsigned flags)
2030+
int write_object_file_literally(const void *buf, unsigned long len,
2031+
const char *type, struct object_id *oid,
2032+
unsigned flags)
20332033
{
20342034
char *header;
20352035
int hdrlen, status = 0;

object-store.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ static inline int write_object_file(const void *buf, unsigned long len,
258258
return write_object_file_flags(buf, len, type, oid, 0);
259259
}
260260

261-
int hash_object_file_literally(const void *buf, unsigned long len,
262-
const char *type, struct object_id *oid,
263-
unsigned flags);
261+
int write_object_file_literally(const void *buf, unsigned long len,
262+
const char *type, struct object_id *oid,
263+
unsigned flags);
264264

265265
/*
266266
* Add an object file to the in-memory object store, without writing it

0 commit comments

Comments
 (0)