object-file: split up concerns of HASH_* flags

The functions `hash_object_file()`, `write_object_file()` and
`index_fd()` reuse the same set of flags to alter their behaviour. This
not only adds confusion, but given that every function only supports a
subset of the flags it becomes very hard to see which flags can be
passed to what function. Last but not least, this entangles the
implementation of all three function families.

Split up concerns by creating separate flags for each of the function
families.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-04-15 11:38:19 +02:00
committed by Junio C Hamano
parent d9f517d051
commit 70c0f9db4e
9 changed files with 56 additions and 28 deletions

View File

@@ -305,7 +305,7 @@ static int import_object(struct object_id *oid, enum object_type type,
strbuf_release(&result);
} else {
struct stat st;
int flags = HASH_FORMAT_CHECK | HASH_WRITE_OBJECT;
int flags = INDEX_FORMAT_CHECK | INDEX_WRITE_OBJECT;
if (fstat(fd, &st) < 0) {
error_errno(_("unable to fstat %s"), filename);