Skip to content

Commit 3df51ea

Browse files
committed
Merge branch 'eb/limit-bulk-checkin-to-blobs'
The "streaming" interface used for bulk-checkin codepath has been narrowed to take only blob objects for now, with no real loss of functionality. * eb/limit-bulk-checkin-to-blobs: bulk-checkin: only support blobs in index_bulk_checkin
2 parents 3a06386 + 9eb5419 commit 3df51ea

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

bulk-checkin.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ static int already_written(struct bulk_checkin_packfile *state, struct object_id
155155
* status before calling us just in case we ask it to call us again
156156
* with a new pack.
157157
*/
158-
static int stream_to_pack(struct bulk_checkin_packfile *state,
159-
git_hash_ctx *ctx, off_t *already_hashed_to,
160-
int fd, size_t size, enum object_type type,
161-
const char *path, unsigned flags)
158+
static int stream_blob_to_pack(struct bulk_checkin_packfile *state,
159+
git_hash_ctx *ctx, off_t *already_hashed_to,
160+
int fd, size_t size, const char *path,
161+
unsigned flags)
162162
{
163163
git_zstream s;
164164
unsigned char ibuf[16384];
@@ -170,7 +170,7 @@ static int stream_to_pack(struct bulk_checkin_packfile *state,
170170

171171
git_deflate_init(&s, pack_compression_level);
172172

173-
hdrlen = encode_in_pack_object_header(obuf, sizeof(obuf), type, size);
173+
hdrlen = encode_in_pack_object_header(obuf, sizeof(obuf), OBJ_BLOB, size);
174174
s.next_out = obuf + hdrlen;
175175
s.avail_out = sizeof(obuf) - hdrlen;
176176

@@ -247,11 +247,10 @@ static void prepare_to_stream(struct bulk_checkin_packfile *state,
247247
die_errno("unable to write pack header");
248248
}
249249

250-
static int deflate_to_pack(struct bulk_checkin_packfile *state,
251-
struct object_id *result_oid,
252-
int fd, size_t size,
253-
enum object_type type, const char *path,
254-
unsigned flags)
250+
static int deflate_blob_to_pack(struct bulk_checkin_packfile *state,
251+
struct object_id *result_oid,
252+
int fd, size_t size,
253+
const char *path, unsigned flags)
255254
{
256255
off_t seekback, already_hashed_to;
257256
git_hash_ctx ctx;
@@ -265,7 +264,7 @@ static int deflate_to_pack(struct bulk_checkin_packfile *state,
265264
return error("cannot find the current offset");
266265

267266
header_len = format_object_header((char *)obuf, sizeof(obuf),
268-
type, size);
267+
OBJ_BLOB, size);
269268
the_hash_algo->init_fn(&ctx);
270269
the_hash_algo->update_fn(&ctx, obuf, header_len);
271270
the_hash_algo->init_fn(&checkpoint.ctx);
@@ -283,8 +282,8 @@ static int deflate_to_pack(struct bulk_checkin_packfile *state,
283282
idx->offset = state->offset;
284283
crc32_begin(state->f);
285284
}
286-
if (!stream_to_pack(state, &ctx, &already_hashed_to,
287-
fd, size, type, path, flags))
285+
if (!stream_blob_to_pack(state, &ctx, &already_hashed_to,
286+
fd, size, path, flags))
288287
break;
289288
/*
290289
* Writing this object to the current pack will make
@@ -351,12 +350,12 @@ void fsync_loose_object_bulk_checkin(int fd, const char *filename)
351350
}
352351
}
353352

354-
int index_bulk_checkin(struct object_id *oid,
355-
int fd, size_t size, enum object_type type,
356-
const char *path, unsigned flags)
353+
int index_blob_bulk_checkin(struct object_id *oid,
354+
int fd, size_t size,
355+
const char *path, unsigned flags)
357356
{
358-
int status = deflate_to_pack(&bulk_checkin_packfile, oid, fd, size, type,
359-
path, flags);
357+
int status = deflate_blob_to_pack(&bulk_checkin_packfile, oid, fd, size,
358+
path, flags);
360359
if (!odb_transaction_nesting)
361360
flush_bulk_checkin_packfile(&bulk_checkin_packfile);
362361
return status;

bulk-checkin.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
void prepare_loose_object_bulk_checkin(void);
1010
void fsync_loose_object_bulk_checkin(int fd, const char *filename);
1111

12-
int index_bulk_checkin(struct object_id *oid,
13-
int fd, size_t size, enum object_type type,
14-
const char *path, unsigned flags);
12+
int index_blob_bulk_checkin(struct object_id *oid,
13+
int fd, size_t size,
14+
const char *path, unsigned flags);
1515

1616
/*
1717
* Tell the object database to optimize for adding

object-file.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,11 +2446,11 @@ static int index_core(struct index_state *istate,
24462446
* binary blobs, they generally do not want to get any conversion, and
24472447
* callers should avoid this code path when filters are requested.
24482448
*/
2449-
static int index_stream(struct object_id *oid, int fd, size_t size,
2450-
enum object_type type, const char *path,
2451-
unsigned flags)
2449+
static int index_blob_stream(struct object_id *oid, int fd, size_t size,
2450+
const char *path,
2451+
unsigned flags)
24522452
{
2453-
return index_bulk_checkin(oid, fd, size, type, path, flags);
2453+
return index_blob_bulk_checkin(oid, fd, size, path, flags);
24542454
}
24552455

24562456
int index_fd(struct index_state *istate, struct object_id *oid,
@@ -2472,8 +2472,8 @@ int index_fd(struct index_state *istate, struct object_id *oid,
24722472
ret = index_core(istate, oid, fd, xsize_t(st->st_size),
24732473
type, path, flags);
24742474
else
2475-
ret = index_stream(oid, fd, xsize_t(st->st_size), type, path,
2476-
flags);
2475+
ret = index_blob_stream(oid, fd, xsize_t(st->st_size), path,
2476+
flags);
24772477
close(fd);
24782478
return ret;
24792479
}

0 commit comments

Comments
 (0)