summaryrefslogtreecommitdiffstats
path: root/replace-object.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-05-08 15:59:21 +0900
committerJunio C Hamano <gitster@pobox.com>2018-05-08 15:59:21 +0900
commit174774cd519846616edc475fcbc98237409ffc21 (patch)
tree604a92001e30c35c702e341c2aa835e41ce3a113 /replace-object.h
parentb10edb2df55241b2e042b3d5473537904d09d193 (diff)
parent90e777f1e20dd6bdc022d5720a9169ea2205d9ad (diff)
downloadgit-174774cd519846616edc475fcbc98237409ffc21.tar.gz
git-174774cd519846616edc475fcbc98237409ffc21.zip
Merge branch 'sb/object-store-replace'
The effort to pass the repository in-core structure throughout the API continues. This round deals with the code that implements the refs/replace/ mechanism. * sb/object-store-replace: replace-object: allow lookup_replace_object to handle arbitrary repositories replace-object: allow do_lookup_replace_object to handle arbitrary repositories replace-object: allow prepare_replace_object to handle arbitrary repositories refs: allow for_each_replace_ref to handle arbitrary repositories refs: store the main ref store inside the repository struct replace-object: add repository argument to lookup_replace_object replace-object: add repository argument to do_lookup_replace_object replace-object: add repository argument to prepare_replace_object refs: add repository argument to for_each_replace_ref refs: add repository argument to get_main_ref_store replace-object: check_replace_refs is safe in multi repo environment replace-object: eliminate replace objects prepared flag object-store: move lookup_replace_object to replace-object.h replace-object: move replace_map to object store replace_object: use oidmap
Diffstat (limited to 'replace-object.h')
-rw-r--r--replace-object.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/replace-object.h b/replace-object.h
new file mode 100644
index 0000000000..f996de3d62
--- /dev/null
+++ b/replace-object.h
@@ -0,0 +1,36 @@
+#ifndef REPLACE_OBJECT_H
+#define REPLACE_OBJECT_H
+
+#include "oidmap.h"
+#include "repository.h"
+#include "object-store.h"
+
+struct replace_object {
+ struct oidmap_entry original;
+ struct object_id replacement;
+};
+
+/*
+ * This internal function is only declared here for the benefit of
+ * lookup_replace_object(). Please do not call it directly.
+ */
+extern const struct object_id *do_lookup_replace_object(struct repository *r,
+ const struct object_id *oid);
+
+/*
+ * If object sha1 should be replaced, return the replacement object's
+ * name (replaced recursively, if necessary). The return value is
+ * either sha1 or a pointer to a permanently-allocated value. When
+ * object replacement is suppressed, always return sha1.
+ */
+static inline const struct object_id *lookup_replace_object(struct repository *r,
+ const struct object_id *oid)
+{
+ if (!check_replace_refs ||
+ (r->objects->replace_map &&
+ r->objects->replace_map->map.tablesize == 0))
+ return oid;
+ return do_lookup_replace_object(r, oid);
+}
+
+#endif /* REPLACE_OBJECT_H */