]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ps/odb-make-creation-pluggable' into seen
authorJunio C Hamano <gitster@pobox.com>
Thu, 30 Jul 2026 17:44:39 +0000 (10:44 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Jul 2026 17:44:39 +0000 (10:44 -0700)
The creation of the on-disk data structures for the object database
has been made pluggable, allowing future backends to customize their
setup.  As part of this, the initialization of the object database
has been deferred, and the loading of the loose-object map has been
detangled from repository initialization.

* ps/odb-make-creation-pluggable:
  odb: make creation of on-disk structures pluggable
  odb/source: introduce function to map source type to name
  setup: defer object database creation
  setup: detangle loading of loose object maps
  loose: load loose object map for the correct source

1  2 
loose.c
odb/source-files.c
odb/source-files.h
odb/source-loose.c
odb/source.h
repository.c
setup.c

diff --cc loose.c
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc odb/source.h
Simple merge
diff --cc repository.c
Simple merge
diff --cc setup.c
index 95909e9603126257dc77582d8887f8b559ed5e84,14ef119cb793b6ec6241fc8d566b639b9c819edf..c6b05ea4aadb1d34e74172fee3d67d026267559f
+++ b/setup.c
@@@ -2653,29 -2663,40 +2663,41 @@@ static int create_default_files(struct 
        return reinit;
  }
  
- static void create_object_directory(struct repository *repo)
+ static void create_object_database(struct repository *repo)
  {
-       struct strbuf path = STRBUF_INIT;
-       size_t baselen;
+       char *object_directory, *alternate_object_directories;
  
-       strbuf_addstr(&path, repo_get_object_directory(repo));
-       baselen = path.len;
+       get_object_directories(&object_directory, &alternate_object_directories);
  
-       safe_create_dir(repo, path.buf, 1);
+       /*
+        * Create the "objects" directory in the common directory. This is done
+        * so that the repository can be discovered regardless of the backend
+        * used.
+        *
+        * Note that we only do this in case the object directory wasn't
+        * overwritten via an environment variable. If it _is_ being overridden
+        * then we skip this step, as the repository won't be discoverable
+        * anyway without the environment variable.
+        */
+       if (!object_directory) {
+               struct strbuf objects_dir = STRBUF_INIT;
+               repo_common_path_append(repo, &objects_dir, "objects");
+               safe_create_dir(repo, objects_dir.buf, 1);
+               strbuf_release(&objects_dir);
+       }
  
-       strbuf_setlen(&path, baselen);
-       strbuf_addstr(&path, "/pack");
-       safe_create_dir(repo, path.buf, 1);
+       repo->objects = odb_new(repo, object_directory,
+                               alternate_object_directories);
  
-       strbuf_setlen(&path, baselen);
-       strbuf_addstr(&path, "/info");
-       safe_create_dir(repo, path.buf, 1);
+       if (odb_source_create_on_disk(repo->objects->sources) < 0)
+               die("failed creating object database");
  
-       strbuf_release(&path);
+       free(alternate_object_directories);
+       free(object_directory);
  }
  
 -static void separate_git_dir(const char *git_dir, const char *git_link)
 +static void separate_git_dir(struct repository *repo,
 +                           const char *git_dir, const char *git_link)
  {
        struct stat st;