Skip to content

Commit 98a3bea

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]>
1 parent aab6135 commit 98a3bea

File tree

9 files changed

+126
-126
lines changed

9 files changed

+126
-126
lines changed

builtin/index-pack.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ static void resolve_deltas(void)
12411241
* - append objects to convert thin pack to full pack if required
12421242
* - write the final pack hash
12431243
*/
1244-
static void fix_unresolved_deltas(struct sha1file *f);
1244+
static void fix_unresolved_deltas(struct hashfile *f);
12451245
static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned char *pack_hash)
12461246
{
12471247
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
12521252
}
12531253

12541254
if (fix_thin_pack) {
1255-
struct sha1file *f;
1255+
struct hashfile *f;
12561256
unsigned char read_hash[GIT_MAX_RAWSZ], tail_hash[GIT_MAX_RAWSZ];
12571257
struct strbuf msg = STRBUF_INIT;
12581258
int nr_unresolved = nr_ofs_deltas + nr_ref_deltas - nr_resolved_deltas;
@@ -1262,15 +1262,15 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha
12621262
REALLOC_ARRAY(objects, nr_objects + nr_unresolved + 1);
12631263
memset(objects + nr_objects + 1, 0,
12641264
nr_unresolved * sizeof(*objects));
1265-
f = sha1fd(output_fd, curr_pack);
1265+
f = hashfd(output_fd, curr_pack);
12661266
fix_unresolved_deltas(f);
12671267
strbuf_addf(&msg, Q_("completed with %d local object",
12681268
"completed with %d local objects",
12691269
nr_objects - nr_objects_initial),
12701270
nr_objects - nr_objects_initial);
12711271
stop_progress_msg(&progress, msg.buf);
12721272
strbuf_release(&msg);
1273-
sha1close(f, tail_hash, 0);
1273+
hashclose(f, tail_hash, 0);
12741274
hashcpy(read_hash, pack_hash);
12751275
fixup_pack_header_footer(output_fd, pack_hash,
12761276
curr_pack, nr_objects,
@@ -1286,7 +1286,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha
12861286
nr_ofs_deltas + nr_ref_deltas - nr_resolved_deltas);
12871287
}
12881288

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)
12901290
{
12911291
git_zstream stream;
12921292
int status;
@@ -1300,7 +1300,7 @@ static int write_compressed(struct sha1file *f, void *in, unsigned int size)
13001300
stream.next_out = outbuf;
13011301
stream.avail_out = sizeof(outbuf);
13021302
status = git_deflate(&stream, Z_FINISH);
1303-
sha1write(f, outbuf, sizeof(outbuf) - stream.avail_out);
1303+
hashwrite(f, outbuf, sizeof(outbuf) - stream.avail_out);
13041304
} while (status == Z_OK);
13051305

13061306
if (status != Z_STREAM_END)
@@ -1310,7 +1310,7 @@ static int write_compressed(struct sha1file *f, void *in, unsigned int size)
13101310
return size;
13111311
}
13121312

1313-
static struct object_entry *append_obj_to_pack(struct sha1file *f,
1313+
static struct object_entry *append_obj_to_pack(struct hashfile *f,
13141314
const unsigned char *sha1, void *buf,
13151315
unsigned long size, enum object_type type)
13161316
{
@@ -1327,15 +1327,15 @@ static struct object_entry *append_obj_to_pack(struct sha1file *f,
13271327
}
13281328
header[n++] = c;
13291329
crc32_begin(f);
1330-
sha1write(f, header, n);
1330+
hashwrite(f, header, n);
13311331
obj[0].size = size;
13321332
obj[0].hdr_size = n;
13331333
obj[0].type = type;
13341334
obj[0].real_type = type;
13351335
obj[1].idx.offset = obj[0].idx.offset + n;
13361336
obj[1].idx.offset += write_compressed(f, buf, size);
13371337
obj[0].idx.crc32 = crc32_end(f);
1338-
sha1flush(f);
1338+
hashflush(f);
13391339
hashcpy(obj->idx.oid.hash, sha1);
13401340
return obj;
13411341
}
@@ -1347,7 +1347,7 @@ static int delta_pos_compare(const void *_a, const void *_b)
13471347
return a->obj_no - b->obj_no;
13481348
}
13491349

1350-
static void fix_unresolved_deltas(struct sha1file *f)
1350+
static void fix_unresolved_deltas(struct hashfile *f)
13511351
{
13521352
struct ref_delta_entry **sorted_by_pos;
13531353
int i;

builtin/pack-objects.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static unsigned long do_compress(void **pptr, unsigned long size)
161161
return stream.total_out;
162162
}
163163

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,
165165
const struct object_id *oid)
166166
{
167167
git_zstream stream;
@@ -185,7 +185,7 @@ static unsigned long write_large_blob_data(struct git_istream *st, struct sha1fi
185185
stream.next_out = obuf;
186186
stream.avail_out = sizeof(obuf);
187187
zret = git_deflate(&stream, readlen ? 0 : Z_FINISH);
188-
sha1write(f, obuf, stream.next_out - obuf);
188+
hashwrite(f, obuf, stream.next_out - obuf);
189189
olen += stream.next_out - obuf;
190190
}
191191
if (stream.avail_in)
@@ -230,7 +230,7 @@ static int check_pack_inflate(struct packed_git *p,
230230
stream.total_in == len) ? 0 : -1;
231231
}
232232

233-
static void copy_pack_data(struct sha1file *f,
233+
static void copy_pack_data(struct hashfile *f,
234234
struct packed_git *p,
235235
struct pack_window **w_curs,
236236
off_t offset,
@@ -243,14 +243,14 @@ static void copy_pack_data(struct sha1file *f,
243243
in = use_pack(p, w_curs, offset, &avail);
244244
if (avail > len)
245245
avail = (unsigned long)len;
246-
sha1write(f, in, avail);
246+
hashwrite(f, in, avail);
247247
offset += avail;
248248
len -= avail;
249249
}
250250
}
251251

252252
/* 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,
254254
unsigned long limit, int usable_delta)
255255
{
256256
unsigned long size, datalen;
@@ -323,8 +323,8 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
323323
free(buf);
324324
return 0;
325325
}
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);
328328
hdrlen += sizeof(dheader) - pos;
329329
} else if (type == OBJ_REF_DELTA) {
330330
/*
@@ -337,8 +337,8 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
337337
free(buf);
338338
return 0;
339339
}
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);
342342
hdrlen += 20;
343343
} else {
344344
if (limit && hdrlen + datalen + 20 >= limit) {
@@ -347,21 +347,21 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
347347
free(buf);
348348
return 0;
349349
}
350-
sha1write(f, header, hdrlen);
350+
hashwrite(f, header, hdrlen);
351351
}
352352
if (st) {
353353
datalen = write_large_blob_data(st, f, &entry->idx.oid);
354354
close_istream(st);
355355
} else {
356-
sha1write(f, buf, datalen);
356+
hashwrite(f, buf, datalen);
357357
free(buf);
358358
}
359359

360360
return hdrlen + datalen;
361361
}
362362

363363
/* 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,
365365
unsigned long limit, int usable_delta)
366366
{
367367
struct packed_git *p = entry->in_pack;
@@ -412,25 +412,25 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
412412
unuse_pack(&w_curs);
413413
return 0;
414414
}
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);
417417
hdrlen += sizeof(dheader) - pos;
418418
reused_delta++;
419419
} else if (type == OBJ_REF_DELTA) {
420420
if (limit && hdrlen + 20 + datalen + 20 >= limit) {
421421
unuse_pack(&w_curs);
422422
return 0;
423423
}
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);
426426
hdrlen += 20;
427427
reused_delta++;
428428
} else {
429429
if (limit && hdrlen + datalen + 20 >= limit) {
430430
unuse_pack(&w_curs);
431431
return 0;
432432
}
433-
sha1write(f, header, hdrlen);
433+
hashwrite(f, header, hdrlen);
434434
}
435435
copy_pack_data(f, p, &w_curs, offset, datalen);
436436
unuse_pack(&w_curs);
@@ -439,7 +439,7 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
439439
}
440440

441441
/* 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,
443443
struct object_entry *entry,
444444
off_t write_offset)
445445
{
@@ -512,7 +512,7 @@ enum write_one_status {
512512
WRITE_ONE_RECURSIVE = 2 /* already scheduled to be written */
513513
};
514514

515-
static enum write_one_status write_one(struct sha1file *f,
515+
static enum write_one_status write_one(struct hashfile *f,
516516
struct object_entry *e,
517517
off_t *offset)
518518
{
@@ -731,7 +731,7 @@ static struct object_entry **compute_write_order(void)
731731
return wo;
732732
}
733733

734-
static off_t write_reused_pack(struct sha1file *f)
734+
static off_t write_reused_pack(struct hashfile *f)
735735
{
736736
unsigned char buffer[8192];
737737
off_t to_write, total;
@@ -762,7 +762,7 @@ static off_t write_reused_pack(struct sha1file *f)
762762
if (read_pack > to_write)
763763
read_pack = to_write;
764764

765-
sha1write(f, buffer, read_pack);
765+
hashwrite(f, buffer, read_pack);
766766
to_write -= read_pack;
767767

768768
/*
@@ -791,7 +791,7 @@ static const char no_split_warning[] = N_(
791791
static void write_pack_file(void)
792792
{
793793
uint32_t i = 0, j;
794-
struct sha1file *f;
794+
struct hashfile *f;
795795
off_t offset;
796796
uint32_t nr_remaining = nr_result;
797797
time_t last_mtime = 0;
@@ -807,7 +807,7 @@ static void write_pack_file(void)
807807
char *pack_tmp_name = NULL;
808808

809809
if (pack_to_stdout)
810-
f = sha1fd_throughput(1, "<stdout>", progress_state);
810+
f = hashfd_throughput(1, "<stdout>", progress_state);
811811
else
812812
f = create_tmp_packfile(&pack_tmp_name);
813813

@@ -834,11 +834,11 @@ static void write_pack_file(void)
834834
* If so, rewrite it like in fast-import
835835
*/
836836
if (pack_to_stdout) {
837-
sha1close(f, oid.hash, CSUM_CLOSE);
837+
hashclose(f, oid.hash, CSUM_CLOSE);
838838
} else if (nr_written == nr_remaining) {
839-
sha1close(f, oid.hash, CSUM_FSYNC);
839+
hashclose(f, oid.hash, CSUM_FSYNC);
840840
} else {
841-
int fd = sha1close(f, oid.hash, 0);
841+
int fd = hashclose(f, oid.hash, 0);
842842
fixup_pack_header_footer(fd, oid.hash, pack_tmp_name,
843843
nr_written, oid.hash, offset);
844844
close(fd);

bulk-checkin.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static struct bulk_checkin_state {
1212
unsigned plugged:1;
1313

1414
char *pack_tmp_name;
15-
struct sha1file *f;
15+
struct hashfile *f;
1616
off_t offset;
1717
struct pack_idx_option pack_idx_opts;
1818

@@ -35,9 +35,9 @@ static void finish_bulk_checkin(struct bulk_checkin_state *state)
3535
unlink(state->pack_tmp_name);
3636
goto clear_exit;
3737
} else if (state->nr_written == 1) {
38-
sha1close(state->f, oid.hash, CSUM_FSYNC);
38+
hashclose(state->f, oid.hash, CSUM_FSYNC);
3939
} else {
40-
int fd = sha1close(state->f, oid.hash, 0);
40+
int fd = hashclose(state->f, oid.hash, 0);
4141
fixup_pack_header_footer(fd, oid.hash, state->pack_tmp_name,
4242
state->nr_written, oid.hash,
4343
state->offset);
@@ -149,7 +149,7 @@ static int stream_to_pack(struct bulk_checkin_state *state,
149149
return -1;
150150
}
151151

152-
sha1write(state->f, obuf, written);
152+
hashwrite(state->f, obuf, written);
153153
state->offset += written;
154154
}
155155
s.next_out = obuf;
@@ -195,7 +195,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
195195
git_SHA_CTX ctx;
196196
unsigned char obuf[16384];
197197
unsigned header_len;
198-
struct sha1file_checkpoint checkpoint;
198+
struct hashfile_checkpoint checkpoint;
199199
struct pack_idx_entry *idx = NULL;
200200

201201
seekback = lseek(fd, 0, SEEK_CUR);
@@ -216,7 +216,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
216216
while (1) {
217217
prepare_to_stream(state, flags);
218218
if (idx) {
219-
sha1file_checkpoint(state->f, &checkpoint);
219+
hashfile_checkpoint(state->f, &checkpoint);
220220
idx->offset = state->offset;
221221
crc32_begin(state->f);
222222
}
@@ -230,7 +230,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
230230
*/
231231
if (!idx)
232232
die("BUG: should not happen");
233-
sha1file_truncate(state->f, &checkpoint);
233+
hashfile_truncate(state->f, &checkpoint);
234234
state->offset = checkpoint.offset;
235235
finish_bulk_checkin(state);
236236
if (lseek(fd, seekback, SEEK_SET) == (off_t) -1)
@@ -242,7 +242,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
242242

243243
idx->crc32 = crc32_end(state->f);
244244
if (already_written(state, result_sha1)) {
245-
sha1file_truncate(state->f, &checkpoint);
245+
hashfile_truncate(state->f, &checkpoint);
246246
state->offset = checkpoint.offset;
247247
free(idx);
248248
} else {

0 commit comments

Comments
 (0)