Skip to content

Commit b393ce3

Browse files
committed
Merge branch 'jt/odb-transaction-write' into seen
ODB transaction interface is being reworked to explicitly handle object writes. Comments? * jt/odb-transaction-write: odb/transaction: make `write_object_stream()` pluggable object-file: generalize packfile writes to use odb_write_stream object-file: avoid fd seekback by checking object size upfront object-file: remove flags from transaction packfile writes odb: update `struct odb_write_stream` read() callback odb/transaction: use pluggable `begin_transaction()` odb: split `struct odb_transaction` into separate header
2 parents a74e964 + ddf6aee commit b393ce3

File tree

14 files changed

+306
-216
lines changed

14 files changed

+306
-216
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,7 @@ LIB_OBJS += odb.o
12201220
LIB_OBJS += odb/source.o
12211221
LIB_OBJS += odb/source-files.o
12221222
LIB_OBJS += odb/streaming.o
1223+
LIB_OBJS += odb/transaction.o
12231224
LIB_OBJS += oid-array.o
12241225
LIB_OBJS += oidmap.o
12251226
LIB_OBJS += oidset.o

builtin/add.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "run-command.h"
1717
#include "object-file.h"
1818
#include "odb.h"
19+
#include "odb/transaction.h"
1920
#include "parse-options.h"
2021
#include "path.h"
2122
#include "preload-index.h"

builtin/unpack-objects.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "hex.h"
1010
#include "object-file.h"
1111
#include "odb.h"
12+
#include "odb/streaming.h"
13+
#include "odb/transaction.h"
1214
#include "object.h"
1315
#include "delta.h"
1416
#include "pack.h"
@@ -359,34 +361,29 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size,
359361

360362
struct input_zstream_data {
361363
git_zstream *zstream;
362-
unsigned char buf[8192];
363364
int status;
364365
};
365366

366-
static const void *feed_input_zstream(struct odb_write_stream *in_stream,
367-
unsigned long *readlen)
367+
static ssize_t feed_input_zstream(struct odb_write_stream *in_stream,
368+
unsigned char *buf, size_t buf_len)
368369
{
369370
struct input_zstream_data *data = in_stream->data;
370371
git_zstream *zstream = data->zstream;
371372
void *in = fill(1);
372373

373-
if (in_stream->is_finished) {
374-
*readlen = 0;
375-
return NULL;
376-
}
374+
if (in_stream->is_finished)
375+
return 0;
377376

378-
zstream->next_out = data->buf;
379-
zstream->avail_out = sizeof(data->buf);
377+
zstream->next_out = buf;
378+
zstream->avail_out = buf_len;
380379
zstream->next_in = in;
381380
zstream->avail_in = len;
382381

383382
data->status = git_inflate(zstream, 0);
384383

385384
in_stream->is_finished = data->status != Z_OK;
386385
use(len - zstream->avail_in);
387-
*readlen = sizeof(data->buf) - zstream->avail_out;
388-
389-
return data->buf;
386+
return buf_len - zstream->avail_out;
390387
}
391388

392389
static void stream_blob(unsigned long size, unsigned nr)

builtin/update-index.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "tree-walk.h"
2020
#include "object-file.h"
2121
#include "odb.h"
22+
#include "odb/transaction.h"
2223
#include "refs.h"
2324
#include "resolve-undo.h"
2425
#include "parse-options.h"

cache-tree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "cache-tree.h"
1111
#include "object-file.h"
1212
#include "odb.h"
13+
#include "odb/transaction.h"
1314
#include "read-cache-ll.h"
1415
#include "replace-object.h"
1516
#include "repository.h"

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ libgit_sources = [
406406
'odb/source.c',
407407
'odb/source-files.c',
408408
'odb/streaming.c',
409+
'odb/transaction.c',
409410
'oid-array.c',
410411
'oidmap.c',
411412
'oidset.c',

0 commit comments

Comments
 (0)