]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ps/odb-pluggable-housekeeping' into next
authorJunio C Hamano <gitster@pobox.com>
Tue, 28 Jul 2026 19:15:03 +0000 (12:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Jul 2026 19:15:03 +0000 (12:15 -0700)
Object database housekeeping in 'git gc' and 'git maintenance' has
been refactored to be pluggable.  The files-backend-specific logic,
including incremental and geometric repacking as well as object
pruning, has been moved out of the command implementation and into the
files object database source, enabling future alternative object
database backends to implement their own housekeeping services.

* ps/odb-pluggable-housekeeping:
  odb: make optimizations pluggable
  builtin/gc: fix signedness issues in ODB-related functionality
  builtin/gc: refactor ODB optimizations to operate on "files" source
  builtin/gc: introduce `odb_optimize_required()`
  builtin/gc: move geometric repacking into `odb_optimize()`
  builtin/gc: introduce object database optimization options
  builtin/gc: inline config values specific to the "files" backend
  builtin/gc: make repack arguments self-contained
  builtin/gc: extract object database optimizations into separate function
  builtin/gc: move worktree and rerere tasks before object optimizations
  odb: run "pre-auto-gc" hook for all maintenance tasks
  t7900: simplify how we check for maintenance tasks

1  2 
builtin/gc.c
odb.c
odb.h
odb/source-files.c
odb/source.h
t/t7900-maintenance.sh

diff --cc builtin/gc.c
index 49c8474fade8ed4d961e25117b9580a896c9c2d7,ac1a21e91267f7709d0f382710eae36c95052f3a..de2f9e7fed5b3e8de685ecdff0c45c85400863b8
@@@ -1789,8 -1412,9 +1412,9 @@@ static int maintenance_run_tasks(struc
        struct lock_file lk;
        struct repository *r = the_repository;
        char *lock_path = xstrfmt("%s/maintenance", r->objects->sources->path);
+       enum auto_gc_hook_result auto_gc_hook_result = AUTO_GC_HOOK_UNDECIDED;
  
 -      if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {
 +      if (repo_hold_lock_file_for_update(r, &lk, lock_path, LOCK_NO_DEREF) < 0) {
                /*
                 * Another maintenance command is running.
                 *
diff --cc odb.c
Simple merge
diff --cc odb.h
Simple merge
Simple merge
diff --cc odb/source.h
index fc04dd5cda880046a0ce89fcd015f45235903c32,88a48ba3c3075ba759cc444e9ae51ffcfc7f5dd1..d69f8e2d1cf626a3b59c750243532068b71c6260
@@@ -478,10 -485,30 +493,31 @@@ static inline int odb_source_write_alte
   * Returns 0 on success, a negative error code otherwise.
   */
  static inline int odb_source_begin_transaction(struct odb_source *source,
 -                                             struct odb_transaction **out)
 +                                             struct odb_transaction **out,
 +                                             enum odb_transaction_flags flags)
  {
 -      return source->begin_transaction(source, out);
 +      return source->begin_transaction(source, out, flags);
  }
  
+ /*
+  * Optimize the object database source. Returns 0 on success, a negative error
+  * code otherwise.
+  */
+ static inline int odb_source_optimize(struct odb_source *source,
+                                     const struct odb_optimize_options *opts)
+ {
+       return source->optimize(source, opts);
+ }
+ /*
+  * Check whether optimization of the object database source is required given
+  * the provided options. Returns true if optimization should be performed,
+  * false otherwise.
+  */
+ static inline bool odb_source_optimize_required(struct odb_source *source,
+                                               const struct odb_optimize_options *opts)
+ {
+       return source->optimize_required(source, opts);
+ }
  #endif
Simple merge