Skip to content

Commit fd13909

Browse files
committed
Merge branch 'jt/odb-transaction'
The work to build on the bulk-checkin infrastructure to create many objects at once in a transaction and to abstract it into the generic object layer continues. * jt/odb-transaction: odb: add transaction interface object-file: update naming from bulk-checkin object-file: relocate ODB transaction code bulk-checkin: drop flush_odb_transaction() builtin/update-index: end ODB transaction when --verbose is specified bulk-checkin: remove ODB transaction nesting
2 parents 821f583 + ce1661f commit fd13909

File tree

13 files changed

+462
-498
lines changed

13 files changed

+462
-498
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,6 @@ LIB_OBJS += blame.o
974974
LIB_OBJS += blob.o
975975
LIB_OBJS += bloom.o
976976
LIB_OBJS += branch.o
977-
LIB_OBJS += bulk-checkin.o
978977
LIB_OBJS += bundle-uri.o
979978
LIB_OBJS += bundle.o
980979
LIB_OBJS += cache-tree.o

builtin/add.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
#include "gettext.h"
1515
#include "pathspec.h"
1616
#include "run-command.h"
17+
#include "object-file.h"
18+
#include "odb.h"
1719
#include "parse-options.h"
1820
#include "path.h"
1921
#include "preload-index.h"
2022
#include "diff.h"
2123
#include "read-cache.h"
2224
#include "revision.h"
23-
#include "bulk-checkin.h"
2425
#include "strvec.h"
2526
#include "submodule.h"
2627
#include "add-interactive.h"
@@ -575,7 +576,7 @@ int cmd_add(int argc,
575576
string_list_clear(&only_match_skip_worktree, 0);
576577
}
577578

578-
transaction = begin_odb_transaction(repo->objects);
579+
transaction = odb_transaction_begin(repo->objects);
579580

580581
ps_matched = xcalloc(pathspec.nr, 1);
581582
if (add_renormalize)
@@ -594,7 +595,7 @@ int cmd_add(int argc,
594595

595596
if (chmod_arg && pathspec.nr)
596597
exit_status |= chmod_pathspec(repo, &pathspec, chmod_arg[0], show_only);
597-
end_odb_transaction(transaction);
598+
odb_transaction_commit(transaction);
598599

599600
finish:
600601
if (write_locked_index(repo->index, &lock_file,

builtin/unpack-objects.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define DISABLE_SIGN_COMPARE_WARNINGS
33

44
#include "builtin.h"
5-
#include "bulk-checkin.h"
65
#include "config.h"
76
#include "environment.h"
87
#include "gettext.h"
@@ -600,12 +599,12 @@ static void unpack_all(void)
600599
progress = start_progress(the_repository,
601600
_("Unpacking objects"), nr_objects);
602601
CALLOC_ARRAY(obj_list, nr_objects);
603-
transaction = begin_odb_transaction(the_repository->objects);
602+
transaction = odb_transaction_begin(the_repository->objects);
604603
for (i = 0; i < nr_objects; i++) {
605604
unpack_one(i);
606605
display_progress(progress, i + 1);
607606
}
608-
end_odb_transaction(transaction);
607+
odb_transaction_commit(transaction);
609608
stop_progress(&progress);
610609

611610
if (delta_list)

builtin/update-index.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#define DISABLE_SIGN_COMPARE_WARNINGS
99

1010
#include "builtin.h"
11-
#include "bulk-checkin.h"
1211
#include "config.h"
1312
#include "environment.h"
1413
#include "gettext.h"
@@ -19,6 +18,7 @@
1918
#include "cache-tree.h"
2019
#include "tree-walk.h"
2120
#include "object-file.h"
21+
#include "odb.h"
2222
#include "refs.h"
2323
#include "resolve-undo.h"
2424
#include "parse-options.h"
@@ -70,14 +70,6 @@ static void report(const char *fmt, ...)
7070
if (!verbose)
7171
return;
7272

73-
/*
74-
* It is possible, though unlikely, that a caller could use the verbose
75-
* output to synchronize with addition of objects to the object
76-
* database. The current implementation of ODB transactions leaves
77-
* objects invisible while a transaction is active, so flush the
78-
* transaction here before reporting a change made by update-index.
79-
*/
80-
flush_odb_transaction(the_repository->objects->transaction);
8173
va_start(vp, fmt);
8274
vprintf(fmt, vp);
8375
putchar('\n');
@@ -1131,7 +1123,7 @@ int cmd_update_index(int argc,
11311123
* Allow the object layer to optimize adding multiple objects in
11321124
* a batch.
11331125
*/
1134-
transaction = begin_odb_transaction(the_repository->objects);
1126+
transaction = odb_transaction_begin(the_repository->objects);
11351127
while (ctx.argc) {
11361128
if (parseopt_state != PARSE_OPT_DONE)
11371129
parseopt_state = parse_options_step(&ctx, options,
@@ -1150,6 +1142,21 @@ int cmd_update_index(int argc,
11501142
const char *path = ctx.argv[0];
11511143
char *p;
11521144

1145+
/*
1146+
* It is possible, though unlikely, that a caller could
1147+
* use the verbose output to synchronize with addition
1148+
* of objects to the object database. The current
1149+
* implementation of ODB transactions leaves objects
1150+
* invisible while a transaction is active, so end the
1151+
* transaction here early before processing the next
1152+
* update. All further updates are performed outside of
1153+
* a transaction.
1154+
*/
1155+
if (transaction && verbose) {
1156+
odb_transaction_commit(transaction);
1157+
transaction = NULL;
1158+
}
1159+
11531160
setup_work_tree();
11541161
p = prefix_path(prefix, prefix_length, path);
11551162
update_one(p);
@@ -1214,7 +1221,7 @@ int cmd_update_index(int argc,
12141221
/*
12151222
* By now we have added all of the new objects
12161223
*/
1217-
end_odb_transaction(transaction);
1224+
odb_transaction_commit(transaction);
12181225

12191226
if (split_index > 0) {
12201227
if (repo_config_get_split_index(the_repository) == 0)

0 commit comments

Comments
 (0)