]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jt/index-fd-wo-repo-regression-fix-maint' into HEAD
authorJunio C Hamano <gitster@pobox.com>
Wed, 8 Apr 2026 00:34:30 +0000 (17:34 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Apr 2026 00:34:30 +0000 (17:34 -0700)
* jt/index-fd-wo-repo-regression-fix-maint:
  object-file: avoid ODB transaction when not writing objects

1  2 
object-file.c

diff --cc object-file.c
index 4f77ce0982625d996b189d8e6a70e3013f32260d,5d72e65bdece014f96cc2538c3412f5166f7a41f..63408fc29049fbb8d2d4247b0246c9821f584e1f
@@@ -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);