@@ -154,33 +154,6 @@ static unsigned long do_compress(void **pptr, unsigned long size)
154154 return stream .total_out ;
155155}
156156
157- /*
158- * The per-object header is a pretty dense thing, which is
159- * - first byte: low four bits are "size", then three bits of "type",
160- * and the high bit is "size continues".
161- * - each byte afterwards: low seven bits are size continuation,
162- * with the high bit being "size continues"
163- */
164- static int encode_header (enum object_type type , unsigned long size , unsigned char * hdr )
165- {
166- int n = 1 ;
167- unsigned char c ;
168-
169- if (type < OBJ_COMMIT || type > OBJ_REF_DELTA )
170- die ("bad type %d" , type );
171-
172- c = (type << 4 ) | (size & 15 );
173- size >>= 4 ;
174- while (size ) {
175- * hdr ++ = c | 0x80 ;
176- c = size & 0x7f ;
177- size >>= 7 ;
178- n ++ ;
179- }
180- * hdr = c ;
181- return n ;
182- }
183-
184157/*
185158 * we are going to reuse the existing object data as is. make
186159 * sure it is not corrupt.
@@ -321,7 +294,7 @@ static unsigned long write_object(struct sha1file *f,
321294 * The object header is a byte of 'type' followed by zero or
322295 * more bytes of length.
323296 */
324- hdrlen = encode_header (type , size , header );
297+ hdrlen = encode_in_pack_object_header (type , size , header );
325298
326299 if (type == OBJ_OFS_DELTA ) {
327300 /*
@@ -372,7 +345,7 @@ static unsigned long write_object(struct sha1file *f,
372345 if (entry -> delta )
373346 type = (allow_ofs_delta && entry -> delta -> idx .offset ) ?
374347 OBJ_OFS_DELTA : OBJ_REF_DELTA ;
375- hdrlen = encode_header (type , entry -> size , header );
348+ hdrlen = encode_in_pack_object_header (type , entry -> size , header );
376349
377350 offset = entry -> in_pack_offset ;
378351 revidx = find_pack_revindex (p , offset );
0 commit comments