Skip to content

Commit 68ee6df

Browse files
bk2204gitster
authored andcommitted
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>
1 parent d0db9ed commit 68ee6df

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

bulk-checkin.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ static void finish_bulk_checkin(struct bulk_checkin_state *state)
6060
reprepare_packed_git();
6161
}
6262

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)
6464
{
6565
int i;
6666

6767
/* The object may already exist in the repository */
68-
if (has_sha1_file(sha1))
68+
if (has_sha1_file(oid->hash))
6969
return 1;
7070

7171
/* Might want to keep the list sorted */
7272
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))
7474
return 1;
7575

7676
/* This is a new object we need to keep */
@@ -186,7 +186,7 @@ static void prepare_to_stream(struct bulk_checkin_state *state,
186186
}
187187

188188
static int deflate_to_pack(struct bulk_checkin_state *state,
189-
unsigned char result_sha1[],
189+
struct object_id *result_oid,
190190
int fd, size_t size,
191191
enum object_type type, const char *path,
192192
unsigned flags)
@@ -236,17 +236,17 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
236236
if (lseek(fd, seekback, SEEK_SET) == (off_t) -1)
237237
return error("cannot seek back");
238238
}
239-
the_hash_algo->final_fn(result_sha1, &ctx);
239+
the_hash_algo->final_fn(result_oid->hash, &ctx);
240240
if (!idx)
241241
return 0;
242242

243243
idx->crc32 = crc32_end(state->f);
244-
if (already_written(state, result_sha1)) {
244+
if (already_written(state, result_oid)) {
245245
hashfile_truncate(state->f, &checkpoint);
246246
state->offset = checkpoint.offset;
247247
free(idx);
248248
} else {
249-
hashcpy(idx->oid.hash, result_sha1);
249+
oidcpy(&idx->oid, result_oid);
250250
ALLOC_GROW(state->written,
251251
state->nr_written + 1,
252252
state->alloc_written);
@@ -255,11 +255,11 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
255255
return 0;
256256
}
257257

258-
int index_bulk_checkin(unsigned char *sha1,
258+
int index_bulk_checkin(struct object_id *oid,
259259
int fd, size_t size, enum object_type type,
260260
const char *path, unsigned flags)
261261
{
262-
int status = deflate_to_pack(&state, sha1, fd, size, type,
262+
int status = deflate_to_pack(&state, oid, fd, size, type,
263263
path, flags);
264264
if (!state.plugged)
265265
finish_bulk_checkin(&state);

bulk-checkin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#ifndef BULK_CHECKIN_H
55
#define BULK_CHECKIN_H
66

7-
extern int index_bulk_checkin(unsigned char sha1[],
7+
extern int index_bulk_checkin(struct object_id *oid,
88
int fd, size_t size, enum object_type type,
99
const char *path, unsigned flags);
1010

sha1_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1892,7 +1892,7 @@ static int index_stream(struct object_id *oid, int fd, size_t size,
18921892
enum object_type type, const char *path,
18931893
unsigned flags)
18941894
{
1895-
return index_bulk_checkin(oid->hash, fd, size, type, path, flags);
1895+
return index_bulk_checkin(oid, fd, size, type, path, flags);
18961896
}
18971897

18981898
int index_fd(struct object_id *oid, int fd, struct stat *st,

0 commit comments

Comments
 (0)