bulk-checkin: convert index_bulk_checkin to struct object_id
Convert the index_bulk_checkin function, and the static functions it calls, to use pointers to struct object_id. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Mar 12, 2018 at 02:27 UTC
68ee6dfc9e2ed2b6ab4c9bf17aa3b973e93f93d7
3 files changed
+11
-11
bulk-checkin.c
+9
-9
@@ -60,17 +60,17 @@ clear_exit:
60
reprepare_packed_git();
61
}
62
63
-static int already_written(struct bulk_checkin_state *state, unsigned char sha1[])
63
+static int already_written(struct bulk_checkin_state *state, struct object_id *oid)
64
{
65
int i;
66
67
/* The object may already exist in the repository */
68
- if (has_sha1_file(sha1))
68
+ if (has_sha1_file(oid->hash))
69
return 1;
70
71
/* Might want to keep the list sorted */
72
for (i = 0; i < state->nr_written; i++)
73
- if (!hashcmp(state->written[i]->oid.hash, sha1))
73
+ if (!oidcmp(&state->written[i]->oid, oid))
74
return 1;
75
76
/* This is a new object we need to keep */
@@ -186,7 +186,7 @@ static void prepare_to_stream(struct bulk_checkin_state *state,
186
}
187
188
static int deflate_to_pack(struct bulk_checkin_state *state,
189
- unsigned char result_sha1[],
189
+ struct object_id *result_oid,
190
int fd, size_t size,
191
enum object_type type, const char *path,
192
unsigned flags)
@@ -236,17 +236,17 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
236
if (lseek(fd, seekback, SEEK_SET) == (off_t) -1)
237
return error("cannot seek back");
238
}
239
- the_hash_algo->final_fn(result_sha1, &ctx);
239
+ the_hash_algo->final_fn(result_oid->hash, &ctx);
240
if (!idx)
241
return 0;
242
243
idx->crc32 = crc32_end(state->f);
244
- if (already_written(state, result_sha1)) {
244
+ if (already_written(state, result_oid)) {
245
hashfile_truncate(state->f, &checkpoint);
246
state->offset = checkpoint.offset;
247
free(idx);
248
} else {
249
- hashcpy(idx->oid.hash, result_sha1);
249
+ oidcpy(&idx->oid, result_oid);
250
ALLOC_GROW(state->written,
251
state->nr_written + 1,
252
state->alloc_written);
@@ -255,11 +255,11 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
255
return 0;
256
}
257
258
-int index_bulk_checkin(unsigned char *sha1,
258
+int index_bulk_checkin(struct object_id *oid,
259
int fd, size_t size, enum object_type type,
260
const char *path, unsigned flags)
261
{
262
- int status = deflate_to_pack(&state, sha1, fd, size, type,
262
+ int status = deflate_to_pack(&state, oid, fd, size, type,
263
path, flags);
264
if (!state.plugged)
265
finish_bulk_checkin(&state);
bulk-checkin.h
+1
-1
@@ -4,7 +4,7 @@
4
#ifndef BULK_CHECKIN_H
5
#define BULK_CHECKIN_H
6
7
-extern int index_bulk_checkin(unsigned char sha1[],
7
+extern int index_bulk_checkin(struct object_id *oid,
8
int fd, size_t size, enum object_type type,
9
const char *path, unsigned flags);
10
sha1_file.c
+1
-1
@@ -1892,7 +1892,7 @@ static int index_stream(struct object_id *oid, int fd, size_t size,
1892
enum object_type type, const char *path,
1893
unsigned flags)
1894
{
1895
- return index_bulk_checkin(oid->hash, fd, size, type, path, flags);
1895
+ return index_bulk_checkin(oid, fd, size, type, path, flags);
1896
}
1897
1898
int index_fd(struct object_id *oid, int fd, struct stat *st,