@@ -130,12 +130,6 @@ int has_loose_object(const struct object_id *oid)
130130 return check_and_freshen (oid , 0 );
131131}
132132
133- static int format_object_header_literally (char * str , size_t size ,
134- const char * type , size_t objsize )
135- {
136- return xsnprintf (str , size , "%s %" PRIuMAX , type , (uintmax_t )objsize ) + 1 ;
137- }
138-
139133int format_object_header (char * str , size_t size , enum object_type type ,
140134 size_t objsize )
141135{
@@ -144,7 +138,7 @@ int format_object_header(char *str, size_t size, enum object_type type,
144138 if (!name )
145139 BUG ("could not get a type name for 'enum object_type' value %d" , type );
146140
147- return format_object_header_literally (str , size , name , objsize );
141+ return xsnprintf (str , size , "%s %" PRIuMAX , name , ( uintmax_t ) objsize ) + 1 ;
148142}
149143
150144int check_object_signature (struct repository * r , const struct object_id * oid ,
@@ -558,17 +552,6 @@ static void write_object_file_prepare(const struct git_hash_algo *algo,
558552 hash_object_body (algo , & c , buf , len , oid , hdr , hdrlen );
559553}
560554
561- static void write_object_file_prepare_literally (const struct git_hash_algo * algo ,
562- const void * buf , unsigned long len ,
563- const char * type , struct object_id * oid ,
564- char * hdr , int * hdrlen )
565- {
566- struct git_hash_ctx c ;
567-
568- * hdrlen = format_object_header_literally (hdr , * hdrlen , type , len );
569- hash_object_body (algo , & c , buf , len , oid , hdr , hdrlen );
570- }
571-
572555#define CHECK_COLLISION_DEST_VANISHED -2
573556
574557static int check_collision (const char * source , const char * dest )
@@ -698,21 +681,14 @@ int finalize_object_file_flags(const char *tmpfile, const char *filename,
698681 return 0 ;
699682}
700683
701- static void hash_object_file_literally (const struct git_hash_algo * algo ,
702- const void * buf , unsigned long len ,
703- const char * type , struct object_id * oid )
704- {
705- char hdr [MAX_HEADER_LEN ];
706- int hdrlen = sizeof (hdr );
707-
708- write_object_file_prepare_literally (algo , buf , len , type , oid , hdr , & hdrlen );
709- }
710-
711684void hash_object_file (const struct git_hash_algo * algo , const void * buf ,
712685 unsigned long len , enum object_type type ,
713686 struct object_id * oid )
714687{
715- hash_object_file_literally (algo , buf , len , type_name (type ), oid );
688+ char hdr [MAX_HEADER_LEN ];
689+ int hdrlen = sizeof (hdr );
690+
691+ write_object_file_prepare (algo , buf , len , type , oid , hdr , & hdrlen );
716692}
717693
718694/* Finalize a file on disk, and close it. */
@@ -1114,53 +1090,6 @@ int write_object_file_flags(const void *buf, unsigned long len,
11141090 return 0 ;
11151091}
11161092
1117- int write_object_file_literally (const void * buf , unsigned long len ,
1118- const char * type , struct object_id * oid ,
1119- unsigned flags )
1120- {
1121- char * header ;
1122- struct repository * repo = the_repository ;
1123- const struct git_hash_algo * algo = repo -> hash_algo ;
1124- const struct git_hash_algo * compat = repo -> compat_hash_algo ;
1125- struct object_id compat_oid ;
1126- int hdrlen , status = 0 ;
1127- int compat_type = -1 ;
1128-
1129- if (compat ) {
1130- compat_type = type_from_string_gently (type , -1 , 1 );
1131- if (compat_type == OBJ_BLOB )
1132- hash_object_file (compat , buf , len , compat_type ,
1133- & compat_oid );
1134- else if (compat_type != -1 ) {
1135- struct strbuf converted = STRBUF_INIT ;
1136- convert_object_file (the_repository ,
1137- & converted , algo , compat ,
1138- buf , len , compat_type , 0 );
1139- hash_object_file (compat , converted .buf , converted .len ,
1140- compat_type , & compat_oid );
1141- strbuf_release (& converted );
1142- }
1143- }
1144-
1145- /* type string, SP, %lu of the length plus NUL must fit this */
1146- hdrlen = strlen (type ) + MAX_HEADER_LEN ;
1147- header = xmalloc (hdrlen );
1148- write_object_file_prepare_literally (the_hash_algo , buf , len , type ,
1149- oid , header , & hdrlen );
1150-
1151- if (!(flags & WRITE_OBJECT_FILE_PERSIST ))
1152- goto cleanup ;
1153- if (freshen_packed_object (oid ) || freshen_loose_object (oid ))
1154- goto cleanup ;
1155- status = write_loose_object (oid , header , hdrlen , buf , len , 0 , 0 );
1156- if (compat_type != -1 )
1157- return repo_add_loose_object_map (repo , oid , & compat_oid );
1158-
1159- cleanup :
1160- free (header );
1161- return status ;
1162- }
1163-
11641093int force_object_loose (const struct object_id * oid , time_t mtime )
11651094{
11661095 struct repository * repo = the_repository ;
0 commit comments