Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-02-05 02:48:26 +0300
committerJunio C Hamano <gitster@pobox.com>2022-02-26 04:16:31 +0300
commitc80d226a046170b1c8dd82ef72a27373ddd5880e (patch)
treeb4929eb612436c3ec74193cfc99472bc8da443d7 /object-file.c
parentb04cdea46cf5ae60066fa6dd12d5449bf3ef283f (diff)
object-file API: have write_object_file() take "enum object_type"
Change the write_object_file() function to take an "enum object_type" instead of a "const char *type". Its callers either passed {commit,tree,blob,tag}_type and can pass the corresponding OBJ_* type instead, or were hardcoding strings like "blob". This avoids the back & forth fragility where the callers of write_object_file() would have the enum type, and convert it themselves via type_name(). We do have to now do that conversion ourselves before calling write_object_file_prepare(), but those codepaths will be similarly adjusted in subsequent commits. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-file.c')
-rw-r--r--object-file.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/object-file.c b/object-file.c
index 3fcd46cf9e..59eb793e0a 100644
--- a/object-file.c
+++ b/object-file.c
@@ -2014,7 +2014,7 @@ static int freshen_packed_object(const struct object_id *oid)
}
int write_object_file_flags(const void *buf, unsigned long len,
- const char *type, struct object_id *oid,
+ enum object_type type, struct object_id *oid,
unsigned flags)
{
char hdr[MAX_HEADER_LEN];
@@ -2023,7 +2023,7 @@ int write_object_file_flags(const void *buf, unsigned long len,
/* Normally if we have it in the pack then we do not bother writing
* it out into .git/objects/??/?{38} file.
*/
- write_object_file_prepare(the_hash_algo, buf, len, type, oid, hdr,
+ write_object_file_prepare(the_hash_algo, buf, len, type_name(type), oid, hdr,
&hdrlen);
if (freshen_packed_object(oid) || freshen_loose_object(oid))
return 0;
@@ -2162,7 +2162,7 @@ static int index_mem(struct index_state *istate,
}
if (write_object)
- ret = write_object_file(buf, size, type_name(type), oid);
+ ret = write_object_file(buf, size, type, oid);
else
hash_object_file(the_hash_algo, buf, size, type_name(type),
oid);
@@ -2189,7 +2189,7 @@ static int index_stream_convert_blob(struct index_state *istate,
get_conv_flags(flags));
if (write_object)
- ret = write_object_file(sbuf.buf, sbuf.len, type_name(OBJ_BLOB),
+ ret = write_object_file(sbuf.buf, sbuf.len, OBJ_BLOB,
oid);
else
hash_object_file(the_hash_algo, sbuf.buf, sbuf.len,
@@ -2313,7 +2313,7 @@ int index_path(struct index_state *istate, struct object_id *oid,
if (!(flags & HASH_WRITE_OBJECT))
hash_object_file(the_hash_algo, sb.buf, sb.len,
blob_type, oid);
- else if (write_object_file(sb.buf, sb.len, blob_type, oid))
+ else if (write_object_file(sb.buf, sb.len, OBJ_BLOB, oid))
rc = error(_("%s: failed to insert into database"), path);
strbuf_release(&sb);
break;