From: Junio C Hamano Date: Wed, 8 Apr 2026 00:34:30 +0000 (-0700) Subject: Merge branch 'jt/index-fd-wo-repo-regression-fix-maint' into HEAD X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a8a773c28fa618be573be7bce05d37ac4d079a80;p=thirdparty%2Fgit.git Merge branch 'jt/index-fd-wo-repo-regression-fix-maint' into HEAD * jt/index-fd-wo-repo-regression-fix-maint: object-file: avoid ODB transaction when not writing objects --- a8a773c28fa618be573be7bce05d37ac4d079a80 diff --cc object-file.c index 4f77ce0982,5d72e65bde..63408fc290 --- a/object-file.c +++ b/object-file.c @@@ -1661,18 -1648,19 +1689,23 @@@ int index_fd(struct index_state *istate ret = index_core(istate, oid, fd, xsize_t(st->st_size), type, path, flags); } else { - struct object_database *odb = the_repository->objects; - struct odb_transaction_files *files_transaction; - struct odb_transaction *transaction; - - transaction = odb_transaction_begin(odb); - files_transaction = container_of(odb->transaction, - struct odb_transaction_files, - base); - ret = index_blob_packfile_transaction(files_transaction, oid, fd, - xsize_t(st->st_size), - path, flags); - odb_transaction_commit(transaction); + if (flags & INDEX_WRITE_OBJECT) { ++ struct object_database *odb = the_repository->objects; ++ struct odb_transaction_files *files_transaction; + struct odb_transaction *transaction; + - transaction = odb_transaction_begin(the_repository->objects); - ret = index_blob_packfile_transaction(the_repository->objects->transaction, - oid, fd, ++ transaction = odb_transaction_begin(odb); ++ files_transaction = container_of(odb->transaction, ++ struct odb_transaction_files, ++ base); ++ ret = index_blob_packfile_transaction(files_transaction, oid, fd, + xsize_t(st->st_size), + path, flags); + odb_transaction_commit(transaction); + } else { + ret = hash_blob_stream(the_repository->hash_algo, oid, + fd, xsize_t(st->st_size)); + } } close(fd);