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:
committed by
Junio C Hamano
parent
d9f517d051
commit
70c0f9db4e
@@ -706,11 +706,11 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
|
||||
int intent_only = flags & ADD_CACHE_INTENT;
|
||||
int add_option = (ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE|
|
||||
(intent_only ? ADD_CACHE_NEW_ONLY : 0));
|
||||
unsigned hash_flags = pretend ? 0 : HASH_WRITE_OBJECT;
|
||||
unsigned hash_flags = pretend ? 0 : INDEX_WRITE_OBJECT;
|
||||
struct object_id oid;
|
||||
|
||||
if (flags & ADD_CACHE_RENORMALIZE)
|
||||
hash_flags |= HASH_RENORMALIZE;
|
||||
hash_flags |= INDEX_RENORMALIZE;
|
||||
|
||||
if (!S_ISREG(st_mode) && !S_ISLNK(st_mode) && !S_ISDIR(st_mode))
|
||||
return error(_("%s: can only add regular files, symbolic links or git-directories"), path);
|
||||
|
||||
Reference in New Issue
Block a user