csum-file: rename sha1file to hashfile

Rename struct sha1file to struct hashfile, along with all of its related functions. The transformation in this commit was made by global search-and-replace. Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Feb 1, 2018 at 02:18 UTC 98a3beab6a218eeed33c82fef697c0fd8181ea95
9 files changed +126 -126
builtin/index-pack.c
+10 -10
@@ -1241,7 +1241,7 @@ static void resolve_deltas(void)
1241 * - append objects to convert thin pack to full pack if required
1242 * - write the final pack hash
1243 */
1244 -static void fix_unresolved_deltas(struct sha1file *f);
1244 +static void fix_unresolved_deltas(struct hashfile *f);
1245 static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned char *pack_hash)
1246 {
1247 if (nr_ref_deltas + nr_ofs_deltas == nr_resolved_deltas) {
@@ -1252,7 +1252,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha
1252 }
1253
1254 if (fix_thin_pack) {
1255 - struct sha1file *f;
1255 + struct hashfile *f;
1256 unsigned char read_hash[GIT_MAX_RAWSZ], tail_hash[GIT_MAX_RAWSZ];
1257 struct strbuf msg = STRBUF_INIT;
1258 int nr_unresolved = nr_ofs_deltas + nr_ref_deltas - nr_resolved_deltas;
@@ -1262,7 +1262,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha
1262 REALLOC_ARRAY(objects, nr_objects + nr_unresolved + 1);
1263 memset(objects + nr_objects + 1, 0,
1264 nr_unresolved * sizeof(*objects));
1265 - f = sha1fd(output_fd, curr_pack);
1265 + f = hashfd(output_fd, curr_pack);
1266 fix_unresolved_deltas(f);
1267 strbuf_addf(&msg, Q_("completed with %d local object",
1268 "completed with %d local objects",
@@ -1270,7 +1270,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha
1270 nr_objects - nr_objects_initial);
1271 stop_progress_msg(&progress, msg.buf);
1272 strbuf_release(&msg);
1273 - sha1close(f, tail_hash, 0);
1273 + hashclose(f, tail_hash, 0);
1274 hashcpy(read_hash, pack_hash);
1275 fixup_pack_header_footer(output_fd, pack_hash,
1276 curr_pack, nr_objects,
@@ -1286,7 +1286,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha
1286 nr_ofs_deltas + nr_ref_deltas - nr_resolved_deltas);
1287 }
1288
1289 -static int write_compressed(struct sha1file *f, void *in, unsigned int size)
1289 +static int write_compressed(struct hashfile *f, void *in, unsigned int size)
1290 {
1291 git_zstream stream;
1292 int status;
@@ -1300,7 +1300,7 @@ static int write_compressed(struct sha1file *f, void *in, unsigned int size)
1300 stream.next_out = outbuf;
1301 stream.avail_out = sizeof(outbuf);
1302 status = git_deflate(&stream, Z_FINISH);
1303 - sha1write(f, outbuf, sizeof(outbuf) - stream.avail_out);
1303 + hashwrite(f, outbuf, sizeof(outbuf) - stream.avail_out);
1304 } while (status == Z_OK);
1305
1306 if (status != Z_STREAM_END)
@@ -1310,7 +1310,7 @@ static int write_compressed(struct sha1file *f, void *in, unsigned int size)
1310 return size;
1311 }
1312
1313 -static struct object_entry *append_obj_to_pack(struct sha1file *f,
1313 +static struct object_entry *append_obj_to_pack(struct hashfile *f,
1314 const unsigned char *sha1, void *buf,
1315 unsigned long size, enum object_type type)
1316 {
@@ -1327,7 +1327,7 @@ static struct object_entry *append_obj_to_pack(struct sha1file *f,
1327 }
1328 header[n++] = c;
1329 crc32_begin(f);
1330 - sha1write(f, header, n);
1330 + hashwrite(f, header, n);
1331 obj[0].size = size;
1332 obj[0].hdr_size = n;
1333 obj[0].type = type;
@@ -1335,7 +1335,7 @@ static struct object_entry *append_obj_to_pack(struct sha1file *f,
1335 obj[1].idx.offset = obj[0].idx.offset + n;
1336 obj[1].idx.offset += write_compressed(f, buf, size);
1337 obj[0].idx.crc32 = crc32_end(f);
1338 - sha1flush(f);
1338 + hashflush(f);
1339 hashcpy(obj->idx.oid.hash, sha1);
1340 return obj;
1341 }
@@ -1347,7 +1347,7 @@ static int delta_pos_compare(const void *_a, const void *_b)
1347 return a->obj_no - b->obj_no;
1348 }
1349
1350 -static void fix_unresolved_deltas(struct sha1file *f)
1350 +static void fix_unresolved_deltas(struct hashfile *f)
1351 {
1352 struct ref_delta_entry **sorted_by_pos;
1353 int i;
builtin/pack-objects.c
+26 -26
@@ -161,7 +161,7 @@ static unsigned long do_compress(void **pptr, unsigned long size)
161 return stream.total_out;
162 }
163
164 -static unsigned long write_large_blob_data(struct git_istream *st, struct sha1file *f,
164 +static unsigned long write_large_blob_data(struct git_istream *st, struct hashfile *f,
165 const struct object_id *oid)
166 {
167 git_zstream stream;
@@ -185,7 +185,7 @@ static unsigned long write_large_blob_data(struct git_istream *st, struct sha1fi
185 stream.next_out = obuf;
186 stream.avail_out = sizeof(obuf);
187 zret = git_deflate(&stream, readlen ? 0 : Z_FINISH);
188 - sha1write(f, obuf, stream.next_out - obuf);
188 + hashwrite(f, obuf, stream.next_out - obuf);
189 olen += stream.next_out - obuf;
190 }
191 if (stream.avail_in)
@@ -230,7 +230,7 @@ static int check_pack_inflate(struct packed_git *p,
230 stream.total_in == len) ? 0 : -1;
231 }
232
233 -static void copy_pack_data(struct sha1file *f,
233 +static void copy_pack_data(struct hashfile *f,
234 struct packed_git *p,
235 struct pack_window **w_curs,
236 off_t offset,
@@ -243,14 +243,14 @@ static void copy_pack_data(struct sha1file *f,
243 in = use_pack(p, w_curs, offset, &avail);
244 if (avail > len)
245 avail = (unsigned long)len;
246 - sha1write(f, in, avail);
246 + hashwrite(f, in, avail);
247 offset += avail;
248 len -= avail;
249 }
250 }
251
252 /* Return 0 if we will bust the pack-size limit */
253 -static unsigned long write_no_reuse_object(struct sha1file *f, struct object_entry *entry,
253 +static unsigned long write_no_reuse_object(struct hashfile *f, struct object_entry *entry,
254 unsigned long limit, int usable_delta)
255 {
256 unsigned long size, datalen;
@@ -323,8 +323,8 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
323 free(buf);
324 return 0;
325 }
326 - sha1write(f, header, hdrlen);
327 - sha1write(f, dheader + pos, sizeof(dheader) - pos);
326 + hashwrite(f, header, hdrlen);
327 + hashwrite(f, dheader + pos, sizeof(dheader) - pos);
328 hdrlen += sizeof(dheader) - pos;
329 } else if (type == OBJ_REF_DELTA) {
330 /*
@@ -337,8 +337,8 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
337 free(buf);
338 return 0;
339 }
340 - sha1write(f, header, hdrlen);
341 - sha1write(f, entry->delta->idx.oid.hash, 20);
340 + hashwrite(f, header, hdrlen);
341 + hashwrite(f, entry->delta->idx.oid.hash, 20);
342 hdrlen += 20;
343 } else {
344 if (limit && hdrlen + datalen + 20 >= limit) {
@@ -347,13 +347,13 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
347 free(buf);
348 return 0;
349 }
350 - sha1write(f, header, hdrlen);
350 + hashwrite(f, header, hdrlen);
351 }
352 if (st) {
353 datalen = write_large_blob_data(st, f, &entry->idx.oid);
354 close_istream(st);
355 } else {
356 - sha1write(f, buf, datalen);
356 + hashwrite(f, buf, datalen);
357 free(buf);
358 }
359
@@ -361,7 +361,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
361 }
362
363 /* Return 0 if we will bust the pack-size limit */
364 -static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
364 +static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,
365 unsigned long limit, int usable_delta)
366 {
367 struct packed_git *p = entry->in_pack;
@@ -412,8 +412,8 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
412 unuse_pack(&w_curs);
413 return 0;
414 }
415 - sha1write(f, header, hdrlen);
416 - sha1write(f, dheader + pos, sizeof(dheader) - pos);
415 + hashwrite(f, header, hdrlen);
416 + hashwrite(f, dheader + pos, sizeof(dheader) - pos);
417 hdrlen += sizeof(dheader) - pos;
418 reused_delta++;
419 } else if (type == OBJ_REF_DELTA) {
@@ -421,8 +421,8 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
421 unuse_pack(&w_curs);
422 return 0;
423 }
424 - sha1write(f, header, hdrlen);
425 - sha1write(f, entry->delta->idx.oid.hash, 20);
424 + hashwrite(f, header, hdrlen);
425 + hashwrite(f, entry->delta->idx.oid.hash, 20);
426 hdrlen += 20;
427 reused_delta++;
428 } else {
@@ -430,7 +430,7 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
430 unuse_pack(&w_curs);
431 return 0;
432 }
433 - sha1write(f, header, hdrlen);
433 + hashwrite(f, header, hdrlen);
434 }
435 copy_pack_data(f, p, &w_curs, offset, datalen);
436 unuse_pack(&w_curs);
@@ -439,7 +439,7 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
439 }
440
441 /* Return 0 if we will bust the pack-size limit */
442 -static off_t write_object(struct sha1file *f,
442 +static off_t write_object(struct hashfile *f,
443 struct object_entry *entry,
444 off_t write_offset)
445 {
@@ -512,7 +512,7 @@ enum write_one_status {
512 WRITE_ONE_RECURSIVE = 2 /* already scheduled to be written */
513 };
514
515 -static enum write_one_status write_one(struct sha1file *f,
515 +static enum write_one_status write_one(struct hashfile *f,
516 struct object_entry *e,
517 off_t *offset)
518 {
@@ -731,7 +731,7 @@ static struct object_entry **compute_write_order(void)
731 return wo;
732 }
733
734 -static off_t write_reused_pack(struct sha1file *f)
734 +static off_t write_reused_pack(struct hashfile *f)
735 {
736 unsigned char buffer[8192];
737 off_t to_write, total;
@@ -762,7 +762,7 @@ static off_t write_reused_pack(struct sha1file *f)
762 if (read_pack > to_write)
763 read_pack = to_write;
764
765 - sha1write(f, buffer, read_pack);
765 + hashwrite(f, buffer, read_pack);
766 to_write -= read_pack;
767
768 /*
@@ -791,7 +791,7 @@ static const char no_split_warning[] = N_(
791 static void write_pack_file(void)
792 {
793 uint32_t i = 0, j;
794 - struct sha1file *f;
794 + struct hashfile *f;
795 off_t offset;
796 uint32_t nr_remaining = nr_result;
797 time_t last_mtime = 0;
@@ -807,7 +807,7 @@ static void write_pack_file(void)
807 char *pack_tmp_name = NULL;
808
809 if (pack_to_stdout)
810 - f = sha1fd_throughput(1, "<stdout>", progress_state);
810 + f = hashfd_throughput(1, "<stdout>", progress_state);
811 else
812 f = create_tmp_packfile(&pack_tmp_name);
813
@@ -834,11 +834,11 @@ static void write_pack_file(void)
834 * If so, rewrite it like in fast-import
835 */
836 if (pack_to_stdout) {
837 - sha1close(f, oid.hash, CSUM_CLOSE);
837 + hashclose(f, oid.hash, CSUM_CLOSE);
838 } else if (nr_written == nr_remaining) {
839 - sha1close(f, oid.hash, CSUM_FSYNC);
839 + hashclose(f, oid.hash, CSUM_FSYNC);
840 } else {
841 - int fd = sha1close(f, oid.hash, 0);
841 + int fd = hashclose(f, oid.hash, 0);
842 fixup_pack_header_footer(fd, oid.hash, pack_tmp_name,
843 nr_written, oid.hash, offset);
844 close(fd);
bulk-checkin.c
+8 -8
@@ -12,7 +12,7 @@ static struct bulk_checkin_state {
12 unsigned plugged:1;
13
14 char *pack_tmp_name;
15 - struct sha1file *f;
15 + struct hashfile *f;
16 off_t offset;
17 struct pack_idx_option pack_idx_opts;
18
@@ -35,9 +35,9 @@ static void finish_bulk_checkin(struct bulk_checkin_state *state)
35 unlink(state->pack_tmp_name);
36 goto clear_exit;
37 } else if (state->nr_written == 1) {
38 - sha1close(state->f, oid.hash, CSUM_FSYNC);
38 + hashclose(state->f, oid.hash, CSUM_FSYNC);
39 } else {
40 - int fd = sha1close(state->f, oid.hash, 0);
40 + int fd = hashclose(state->f, oid.hash, 0);
41 fixup_pack_header_footer(fd, oid.hash, state->pack_tmp_name,
42 state->nr_written, oid.hash,
43 state->offset);
@@ -149,7 +149,7 @@ static int stream_to_pack(struct bulk_checkin_state *state,
149 return -1;
150 }
151
152 - sha1write(state->f, obuf, written);
152 + hashwrite(state->f, obuf, written);
153 state->offset += written;
154 }
155 s.next_out = obuf;
@@ -195,7 +195,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
195 git_SHA_CTX ctx;
196 unsigned char obuf[16384];
197 unsigned header_len;
198 - struct sha1file_checkpoint checkpoint;
198 + struct hashfile_checkpoint checkpoint;
199 struct pack_idx_entry *idx = NULL;
200
201 seekback = lseek(fd, 0, SEEK_CUR);
@@ -216,7 +216,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
216 while (1) {
217 prepare_to_stream(state, flags);
218 if (idx) {
219 - sha1file_checkpoint(state->f, &checkpoint);
219 + hashfile_checkpoint(state->f, &checkpoint);
220 idx->offset = state->offset;
221 crc32_begin(state->f);
222 }
@@ -230,7 +230,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
230 */
231 if (!idx)
232 die("BUG: should not happen");
233 - sha1file_truncate(state->f, &checkpoint);
233 + hashfile_truncate(state->f, &checkpoint);
234 state->offset = checkpoint.offset;
235 finish_bulk_checkin(state);
236 if (lseek(fd, seekback, SEEK_SET) == (off_t) -1)
@@ -242,7 +242,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
242
243 idx->crc32 = crc32_end(state->f);
244 if (already_written(state, result_sha1)) {
245 - sha1file_truncate(state->f, &checkpoint);
245 + hashfile_truncate(state->f, &checkpoint);
246 state->offset = checkpoint.offset;
247 free(idx);
248 } else {
csum-file.c
+18 -18
@@ -11,7 +11,7 @@
11 #include "progress.h"
12 #include "csum-file.h"
13
14 -static void flush(struct sha1file *f, const void *buf, unsigned int count)
14 +static void flush(struct hashfile *f, const void *buf, unsigned int count)
15 {
16 if (0 <= f->check_fd && count) {
17 unsigned char check_buffer[8192];
@@ -42,7 +42,7 @@ static void flush(struct sha1file *f, const void *buf, unsigned int count)
42 }
43 }
44
45 -void sha1flush(struct sha1file *f)
45 +void hashflush(struct hashfile *f)
46 {
47 unsigned offset = f->offset;
48
@@ -53,11 +53,11 @@ void sha1flush(struct sha1file *f)
53 }
54 }
55
56 -int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
56 +int hashclose(struct hashfile *f, unsigned char *result, unsigned int flags)
57 {
58 int fd;
59
60 - sha1flush(f);
60 + hashflush(f);
61 git_SHA1_Final(f->buffer, &f->ctx);
62 if (result)
63 hashcpy(result, f->buffer);
@@ -86,7 +86,7 @@ int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
86 return fd;
87 }
88
89 -void sha1write(struct sha1file *f, const void *buf, unsigned int count)
89 +void hashwrite(struct hashfile *f, const void *buf, unsigned int count)
90 {
91 while (count) {
92 unsigned offset = f->offset;
@@ -118,15 +118,15 @@ void sha1write(struct sha1file *f, const void *buf, unsigned int count)
118 }
119 }
120
121 -struct sha1file *sha1fd(int fd, const char *name)
121 +struct hashfile *hashfd(int fd, const char *name)
122 {
123 - return sha1fd_throughput(fd, name, NULL);
123 + return hashfd_throughput(fd, name, NULL);
124 }
125
126 -struct sha1file *sha1fd_check(const char *name)
126 +struct hashfile *hashfd_check(const char *name)
127 {
128 int sink, check;
129 - struct sha1file *f;
129 + struct hashfile *f;
130
131 sink = open("/dev/null", O_WRONLY);
132 if (sink < 0)
@@ -134,14 +134,14 @@ struct sha1file *sha1fd_check(const char *name)
134 check = open(name, O_RDONLY);
135 if (check < 0)
136 die_errno("unable to open '%s'", name);
137 - f = sha1fd(sink, name);
137 + f = hashfd(sink, name);
138 f->check_fd = check;
139 return f;
140 }
141
142 -struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp)
142 +struct hashfile *hashfd_throughput(int fd, const char *name, struct progress *tp)
143 {
144 - struct sha1file *f = xmalloc(sizeof(*f));
144 + struct hashfile *f = xmalloc(sizeof(*f));
145 f->fd = fd;
146 f->check_fd = -1;
147 f->offset = 0;
@@ -153,14 +153,14 @@ struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp
153 return f;
154 }
155
156 -void sha1file_checkpoint(struct sha1file *f, struct sha1file_checkpoint *checkpoint)
156 +void hashfile_checkpoint(struct hashfile *f, struct hashfile_checkpoint *checkpoint)
157 {
158 - sha1flush(f);
158 + hashflush(f);
159 checkpoint->offset = f->total;
160 checkpoint->ctx = f->ctx;
161 }
162
163 -int sha1file_truncate(struct sha1file *f, struct sha1file_checkpoint *checkpoint)
163 +int hashfile_truncate(struct hashfile *f, struct hashfile_checkpoint *checkpoint)
164 {
165 off_t offset = checkpoint->offset;
166
@@ -169,17 +169,17 @@ int sha1file_truncate(struct sha1file *f, struct sha1file_checkpoint *checkpoint
169 return -1;
170 f->total = offset;
171 f->ctx = checkpoint->ctx;
172 - f->offset = 0; /* sha1flush() was called in checkpoint */
172 + f->offset = 0; /* hashflush() was called in checkpoint */
173 return 0;
174 }
175
176 -void crc32_begin(struct sha1file *f)
176 +void crc32_begin(struct hashfile *f)
177 {
178 f->crc32 = crc32(0, NULL, 0);
179 f->do_crc = 1;
180 }
181
182 -uint32_t crc32_end(struct sha1file *f)
182 +uint32_t crc32_end(struct hashfile *f)
183 {
184 f->do_crc = 0;
185 return f->crc32;
csum-file.h
+17 -17
@@ -4,7 +4,7 @@
4 struct progress;
5
6 /* A SHA1-protected file */
7 -struct sha1file {
7 +struct hashfile {
8 int fd;
9 int check_fd;
10 unsigned int offset;
@@ -18,36 +18,36 @@ struct sha1file {
18 };
19
20 /* Checkpoint */
21 -struct sha1file_checkpoint {
21 +struct hashfile_checkpoint {
22 off_t offset;
23 git_SHA_CTX ctx;
24 };
25
26 -extern void sha1file_checkpoint(struct sha1file *, struct sha1file_checkpoint *);
27 -extern int sha1file_truncate(struct sha1file *, struct sha1file_checkpoint *);
26 +extern void hashfile_checkpoint(struct hashfile *, struct hashfile_checkpoint *);
27 +extern int hashfile_truncate(struct hashfile *, struct hashfile_checkpoint *);
28
29 -/* sha1close flags */
29 +/* hashclose flags */
30 #define CSUM_CLOSE 1
31 #define CSUM_FSYNC 2
32
33 -extern struct sha1file *sha1fd(int fd, const char *name);
34 -extern struct sha1file *sha1fd_check(const char *name);
35 -extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
36 -extern int sha1close(struct sha1file *, unsigned char *, unsigned int);
37 -extern void sha1write(struct sha1file *, const void *, unsigned int);
38 -extern void sha1flush(struct sha1file *f);
39 -extern void crc32_begin(struct sha1file *);
40 -extern uint32_t crc32_end(struct sha1file *);
33 +extern struct hashfile *hashfd(int fd, const char *name);
34 +extern struct hashfile *hashfd_check(const char *name);
35 +extern struct hashfile *hashfd_throughput(int fd, const char *name, struct progress *tp);
36 +extern int hashclose(struct hashfile *, unsigned char *, unsigned int);
37 +extern void hashwrite(struct hashfile *, const void *, unsigned int);
38 +extern void hashflush(struct hashfile *f);
39 +extern void crc32_begin(struct hashfile *);
40 +extern uint32_t crc32_end(struct hashfile *);
41
42 -static inline void sha1write_u8(struct sha1file *f, uint8_t data)
42 +static inline void hashwrite_u8(struct hashfile *f, uint8_t data)
43 {
44 - sha1write(f, &data, sizeof(data));
44 + hashwrite(f, &data, sizeof(data));
45 }
46
47 -static inline void sha1write_be32(struct sha1file *f, uint32_t data)
47 +static inline void hashwrite_be32(struct hashfile *f, uint32_t data)
48 {
49 data = htonl(data);
50 - sha1write(f, &data, sizeof(data));
50 + hashwrite(f, &data, sizeof(data));
51 }
52
53 #endif
fast-import.c
+14 -14
@@ -316,7 +316,7 @@ static struct atom_str **atom_table;
316 /* The .pack file being generated */
317 static struct pack_idx_option pack_idx_opts;
318 static unsigned int pack_id;
319 -static struct sha1file *pack_file;
319 +static struct hashfile *pack_file;
320 static struct packed_git *pack_data;
321 static struct packed_git **all_packs;
322 static off_t pack_size;
@@ -905,12 +905,12 @@ static void start_packfile(void)
905
906 p->pack_fd = pack_fd;
907 p->do_not_close = 1;
908 - pack_file = sha1fd(pack_fd, p->pack_name);
908 + pack_file = hashfd(pack_fd, p->pack_name);
909
910 hdr.hdr_signature = htonl(PACK_SIGNATURE);
911 hdr.hdr_version = htonl(2);
912 hdr.hdr_entries = 0;
913 - sha1write(pack_file, &hdr, sizeof(hdr));
913 + hashwrite(pack_file, &hdr, sizeof(hdr));
914
915 pack_data = p;
916 pack_size = sizeof(hdr);
@@ -1016,7 +1016,7 @@ static void end_packfile(void)
1016 struct tag *t;
1017
1018 close_pack_windows(pack_data);
1019 - sha1close(pack_file, cur_pack_oid.hash, 0);
1019 + hashclose(pack_file, cur_pack_oid.hash, 0);
1020 fixup_pack_header_footer(pack_data->pack_fd, pack_data->sha1,
1021 pack_data->pack_name, object_count,
1022 cur_pack_oid.hash, pack_size);
@@ -1182,23 +1182,23 @@ static int store_object(
1182
1183 hdrlen = encode_in_pack_object_header(hdr, sizeof(hdr),
1184 OBJ_OFS_DELTA, deltalen);
1185 - sha1write(pack_file, hdr, hdrlen);
1185 + hashwrite(pack_file, hdr, hdrlen);
1186 pack_size += hdrlen;
1187
1188 hdr[pos] = ofs & 127;
1189 while (ofs >>= 7)
1190 hdr[--pos] = 128 | (--ofs & 127);
1191 - sha1write(pack_file, hdr + pos, sizeof(hdr) - pos);
1191 + hashwrite(pack_file, hdr + pos, sizeof(hdr) - pos);
1192 pack_size += sizeof(hdr) - pos;
1193 } else {
1194 e->depth = 0;
1195 hdrlen = encode_in_pack_object_header(hdr, sizeof(hdr),
1196 type, dat->len);
1197 - sha1write(pack_file, hdr, hdrlen);
1197 + hashwrite(pack_file, hdr, hdrlen);
1198 pack_size += hdrlen;
1199 }
1200
1201 - sha1write(pack_file, out, s.total_out);
1201 + hashwrite(pack_file, out, s.total_out);
1202 pack_size += s.total_out;
1203
1204 e->idx.crc32 = crc32_end(pack_file);
@@ -1217,9 +1217,9 @@ static int store_object(
1217 return 0;
1218 }
1219
1220 -static void truncate_pack(struct sha1file_checkpoint *checkpoint)
1220 +static void truncate_pack(struct hashfile_checkpoint *checkpoint)
1221 {
1222 - if (sha1file_truncate(pack_file, checkpoint))
1222 + if (hashfile_truncate(pack_file, checkpoint))
1223 die_errno("cannot truncate pack to skip duplicate");
1224 pack_size = checkpoint->offset;
1225 }
@@ -1235,7 +1235,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
1235 off_t offset;
1236 git_hash_ctx c;
1237 git_zstream s;
1238 - struct sha1file_checkpoint checkpoint;
1238 + struct hashfile_checkpoint checkpoint;
1239 int status = Z_OK;
1240
1241 /* Determine if we should auto-checkpoint. */
@@ -1243,7 +1243,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
1243 || (pack_size + 60 + len) < pack_size)
1244 cycle_packfile();
1245
1246 - sha1file_checkpoint(pack_file, &checkpoint);
1246 + hashfile_checkpoint(pack_file, &checkpoint);
1247 offset = checkpoint.offset;
1248
1249 hdrlen = xsnprintf((char *)out_buf, out_sz, "blob %" PRIuMAX, len) + 1;
@@ -1277,7 +1277,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
1277
1278 if (!s.avail_out || status == Z_STREAM_END) {
1279 size_t n = s.next_out - out_buf;
1280 - sha1write(pack_file, out_buf, n);
1280 + hashwrite(pack_file, out_buf, n);
1281 pack_size += n;
1282 s.next_out = out_buf;
1283 s.avail_out = out_sz;
@@ -1362,7 +1362,7 @@ static void *gfi_unpack_entry(
1362 * the newly written data.
1363 */
1364 close_pack_windows(p);
1365 - sha1flush(pack_file);
1365 + hashflush(pack_file);
1366
1367 /* We have to offer rawsz bytes additional on the end of
1368 * the packfile as the core unpacker code assumes the
pack-bitmap-write.c
+15 -15
@@ -440,19 +440,19 @@ void bitmap_writer_select_commits(struct commit **indexed_commits,
440 }
441
442
443 -static int sha1write_ewah_helper(void *f, const void *buf, size_t len)
443 +static int hashwrite_ewah_helper(void *f, const void *buf, size_t len)
444 {
445 - /* sha1write will die on error */
446 - sha1write(f, buf, len);
445 + /* hashwrite will die on error */
446 + hashwrite(f, buf, len);
447 return len;
448 }
449
450 /**
451 * Write the bitmap index to disk
452 */
453 -static inline void dump_bitmap(struct sha1file *f, struct ewah_bitmap *bitmap)
453 +static inline void dump_bitmap(struct hashfile *f, struct ewah_bitmap *bitmap)
454 {
455 - if (ewah_serialize_to(bitmap, sha1write_ewah_helper, f) < 0)
455 + if (ewah_serialize_to(bitmap, hashwrite_ewah_helper, f) < 0)
456 die("Failed to write bitmap index");
457 }
458
@@ -462,7 +462,7 @@ static const unsigned char *sha1_access(size_t pos, void *table)
462 return index[pos]->oid.hash;
463 }
464
465 -static void write_selected_commits_v1(struct sha1file *f,
465 +static void write_selected_commits_v1(struct hashfile *f,
466 struct pack_idx_entry **index,
467 uint32_t index_nr)
468 {
@@ -477,15 +477,15 @@ static void write_selected_commits_v1(struct sha1file *f,
477 if (commit_pos < 0)
478 die("BUG: trying to write commit not in index");
479
480 - sha1write_be32(f, commit_pos);
481 - sha1write_u8(f, stored->xor_offset);
482 - sha1write_u8(f, stored->flags);
480 + hashwrite_be32(f, commit_pos);
481 + hashwrite_u8(f, stored->xor_offset);
482 + hashwrite_u8(f, stored->flags);
483
484 dump_bitmap(f, stored->write_as);
485 }
486 }
487
488 -static void write_hash_cache(struct sha1file *f,
488 +static void write_hash_cache(struct hashfile *f,
489 struct pack_idx_entry **index,
490 uint32_t index_nr)
491 {
@@ -494,7 +494,7 @@ static void write_hash_cache(struct sha1file *f,
494 for (i = 0; i < index_nr; ++i) {
495 struct object_entry *entry = (struct object_entry *)index[i];
496 uint32_t hash_value = htonl(entry->hash);
497 - sha1write(f, &hash_value, sizeof(hash_value));
497 + hashwrite(f, &hash_value, sizeof(hash_value));
498 }
499 }
500
@@ -511,13 +511,13 @@ void bitmap_writer_finish(struct pack_idx_entry **index,
511 static uint16_t default_version = 1;
512 static uint16_t flags = BITMAP_OPT_FULL_DAG;
513 struct strbuf tmp_file = STRBUF_INIT;
514 - struct sha1file *f;
514 + struct hashfile *f;
515
516 struct bitmap_disk_header header;
517
518 int fd = odb_mkstemp(&tmp_file, "pack/tmp_bitmap_XXXXXX");
519
520 - f = sha1fd(fd, tmp_file.buf);
520 + f = hashfd(fd, tmp_file.buf);
521
522 memcpy(header.magic, BITMAP_IDX_SIGNATURE, sizeof(BITMAP_IDX_SIGNATURE));
523 header.version = htons(default_version);
@@ -525,7 +525,7 @@ void bitmap_writer_finish(struct pack_idx_entry **index,
525 header.entry_count = htonl(writer.selected_nr);
526 hashcpy(header.checksum, writer.pack_checksum);
527
528 - sha1write(f, &header, sizeof(header));
528 + hashwrite(f, &header, sizeof(header));
529 dump_bitmap(f, writer.commits);
530 dump_bitmap(f, writer.trees);
531 dump_bitmap(f, writer.blobs);
@@ -535,7 +535,7 @@ void bitmap_writer_finish(struct pack_idx_entry **index,
535 if (options & BITMAP_OPT_HASH_CACHE)
536 write_hash_cache(f, index, index_nr);
537
538 - sha1close(f, NULL, CSUM_FSYNC);
538 + hashclose(f, NULL, CSUM_FSYNC);
539
540 if (adjust_shared_perm(tmp_file.buf))
541 die_errno("unable to make temporary bitmap file readable");
pack-write.c
+16 -16
@@ -46,7 +46,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
46 int nr_objects, const struct pack_idx_option *opts,
47 const unsigned char *sha1)
48 {
49 - struct sha1file *f;
49 + struct hashfile *f;
50 struct pack_idx_entry **sorted_by_sha, **list, **last;
51 off_t last_obj_offset = 0;
52 uint32_t array[256];
@@ -68,7 +68,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
68
69 if (opts->flags & WRITE_IDX_VERIFY) {
70 assert(index_name);
71 - f = sha1fd_check(index_name);
71 + f = hashfd_check(index_name);
72 } else {
73 if (!index_name) {
74 struct strbuf tmp_file = STRBUF_INIT;
@@ -80,7 +80,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
80 if (fd < 0)
81 die_errno("unable to create '%s'", index_name);
82 }
83 - f = sha1fd(fd, index_name);
83 + f = hashfd(fd, index_name);
84 }
85
86 /* if last object's offset is >= 2^31 we should use index V2 */
@@ -91,7 +91,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
91 struct pack_idx_header hdr;
92 hdr.idx_signature = htonl(PACK_IDX_SIGNATURE);
93 hdr.idx_version = htonl(index_version);
94 - sha1write(f, &hdr, sizeof(hdr));
94 + hashwrite(f, &hdr, sizeof(hdr));
95 }
96
97 /*
@@ -110,7 +110,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
110 array[i] = htonl(next - sorted_by_sha);
111 list = next;
112 }
113 - sha1write(f, array, 256 * 4);
113 + hashwrite(f, array, 256 * 4);
114
115 /*
116 * Write the actual SHA1 entries..
@@ -120,9 +120,9 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
120 struct pack_idx_entry *obj = *list++;
121 if (index_version < 2) {
122 uint32_t offset = htonl(obj->offset);
123 - sha1write(f, &offset, 4);
123 + hashwrite(f, &offset, 4);
124 }
125 - sha1write(f, obj->oid.hash, the_hash_algo->rawsz);
125 + hashwrite(f, obj->oid.hash, the_hash_algo->rawsz);
126 if ((opts->flags & WRITE_IDX_STRICT) &&
127 (i && !oidcmp(&list[-2]->oid, &obj->oid)))
128 die("The same object %s appears twice in the pack",
@@ -137,7 +137,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
137 for (i = 0; i < nr_objects; i++) {
138 struct pack_idx_entry *obj = *list++;
139 uint32_t crc32_val = htonl(obj->crc32);
140 - sha1write(f, &crc32_val, 4);
140 + hashwrite(f, &crc32_val, 4);
141 }
142
143 /* write the 32-bit offset table */
@@ -150,7 +150,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
150 ? (0x80000000 | nr_large_offset++)
151 : obj->offset);
152 offset = htonl(offset);
153 - sha1write(f, &offset, 4);
153 + hashwrite(f, &offset, 4);
154 }
155
156 /* write the large offset table */
@@ -164,25 +164,25 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
164 continue;
165 split[0] = htonl(offset >> 32);
166 split[1] = htonl(offset & 0xffffffff);
167 - sha1write(f, split, 8);
167 + hashwrite(f, split, 8);
168 nr_large_offset--;
169 }
170 }
171
172 - sha1write(f, sha1, the_hash_algo->rawsz);
173 - sha1close(f, NULL, ((opts->flags & WRITE_IDX_VERIFY)
172 + hashwrite(f, sha1, the_hash_algo->rawsz);
173 + hashclose(f, NULL, ((opts->flags & WRITE_IDX_VERIFY)
174 ? CSUM_CLOSE : CSUM_FSYNC));
175 return index_name;
176 }
177
178 -off_t write_pack_header(struct sha1file *f, uint32_t nr_entries)
178 +off_t write_pack_header(struct hashfile *f, uint32_t nr_entries)
179 {
180 struct pack_header hdr;
181
182 hdr.hdr_signature = htonl(PACK_SIGNATURE);
183 hdr.hdr_version = htonl(PACK_VERSION);
184 hdr.hdr_entries = htonl(nr_entries);
185 - sha1write(f, &hdr, sizeof(hdr));
185 + hashwrite(f, &hdr, sizeof(hdr));
186 return sizeof(hdr);
187 }
188
@@ -333,14 +333,14 @@ int encode_in_pack_object_header(unsigned char *hdr, int hdr_len,
333 return n;
334 }
335
336 -struct sha1file *create_tmp_packfile(char **pack_tmp_name)
336 +struct hashfile *create_tmp_packfile(char **pack_tmp_name)
337 {
338 struct strbuf tmpname = STRBUF_INIT;
339 int fd;
340
341 fd = odb_mkstemp(&tmpname, "pack/tmp_pack_XXXXXX");
342 *pack_tmp_name = strbuf_detach(&tmpname, NULL);
343 - return sha1fd(fd, *pack_tmp_name);
343 + return hashfd(fd, *pack_tmp_name);
344 }
345
346 void finish_tmp_packfile(struct strbuf *name_buffer,
pack.h
+2 -2
@@ -81,7 +81,7 @@ extern const char *write_idx_file(const char *index_name, struct pack_idx_entry
81 extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr);
82 extern int verify_pack_index(struct packed_git *);
83 extern int verify_pack(struct packed_git *, verify_fn fn, struct progress *, uint32_t);
84 -extern off_t write_pack_header(struct sha1file *f, uint32_t);
84 +extern off_t write_pack_header(struct hashfile *f, uint32_t);
85 extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t, unsigned char *, off_t);
86 extern char *index_pack_lockfile(int fd);
87
@@ -98,7 +98,7 @@ extern int encode_in_pack_object_header(unsigned char *hdr, int hdr_len,
98 #define PH_ERROR_PROTOCOL (-3)
99 extern int read_pack_header(int fd, struct pack_header *);
100
101 -extern struct sha1file *create_tmp_packfile(char **pack_tmp_name);
101 +extern struct hashfile *create_tmp_packfile(char **pack_tmp_name);
102 extern void finish_tmp_packfile(struct strbuf *name_buffer, const char *pack_tmp_name, struct pack_idx_entry **written_list, uint32_t nr_written, struct pack_idx_option *pack_idx_opts, unsigned char sha1[]);
103
104 #endif