]> git.ipfire.org Git - thirdparty/git.git/blobdiff - repository.c
Merge branch 'tg/glossary-overlay'
[thirdparty/git.git] / repository.c
index 20c509a9226645b1890c8433b22a7182699fc847..682c239fe3eda6c16b7be45fc5c920a325d61817 100644 (file)
@@ -1,13 +1,20 @@
+/*
+ * not really _using_ the compat macros, just make sure the_index
+ * declaration matches the definition in this file.
+ */
+#define USE_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "repository.h"
 #include "object-store.h"
 #include "config.h"
 #include "object.h"
+#include "lockfile.h"
 #include "submodule-config.h"
 
 /* The main repository */
 static struct repository the_repo;
 struct repository *the_repository;
+struct index_state the_index;
 
 void initialize_the_repository(void)
 {
@@ -119,6 +126,8 @@ out:
 void repo_set_worktree(struct repository *repo, const char *path)
 {
        repo->worktree = real_pathdup(path, 1);
+
+       trace2_def_repo(repo);
 }
 
 static int read_and_verify_repository_format(struct repository_format *format,
@@ -148,7 +157,7 @@ int repo_init(struct repository *repo,
              const char *gitdir,
              const char *worktree)
 {
-       struct repository_format format;
+       struct repository_format format = REPOSITORY_FORMAT_INIT;
        memset(repo, 0, sizeof(*repo));
 
        repo->objects = raw_object_store_new();
@@ -165,6 +174,7 @@ int repo_init(struct repository *repo,
        if (worktree)
                repo_set_worktree(repo, worktree);
 
+       clear_repository_format(&format);
        return 0;
 
 error:
@@ -256,3 +266,12 @@ int repo_read_index(struct repository *repo)
 
        return read_index_from(repo->index, repo->index_file, repo->gitdir);
 }
+
+int repo_hold_locked_index(struct repository *repo,
+                          struct lock_file *lf,
+                          int flags)
+{
+       if (!repo->index_file)
+               BUG("the repo hasn't been setup");
+       return hold_lock_file_for_update(lf, repo->index_file, flags);
+}