diff options
Diffstat (limited to 'replace-object.c')
-rw-r--r-- | replace-object.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/replace-object.c b/replace-object.c index 7bd9aba..5232155 100644 --- a/replace-object.c +++ b/replace-object.c @@ -1,6 +1,8 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "gettext.h" +#include "hex.h" #include "oidmap.h" -#include "object-store.h" +#include "object-store-ll.h" #include "replace-object.h" #include "refs.h" #include "repository.h" @@ -9,7 +11,8 @@ static int register_replace_ref(struct repository *r, const char *refname, const struct object_id *oid, - int flag, void *cb_data) + int flag UNUSED, + void *cb_data UNUSED) { /* Get sha1 from refname */ const char *slash = strrchr(refname, '/'); @@ -61,7 +64,7 @@ void prepare_replace_object(struct repository *r) * replacement object's name (replaced recursively, if necessary). * The return value is either oid or a pointer to a * permanently-allocated value. This function always respects replace - * references, regardless of the value of read_replace_refs. + * references, regardless of the value of r->settings.read_replace_refs. */ const struct object_id *do_lookup_replace_object(struct repository *r, const struct object_id *oid) @@ -81,3 +84,29 @@ const struct object_id *do_lookup_replace_object(struct repository *r, } die(_("replace depth too high for object %s"), oid_to_hex(oid)); } + +/* + * This indicator determines whether replace references should be + * respected process-wide, regardless of which repository is being + * using at the time. + */ +static int read_replace_refs = 1; + +void disable_replace_refs(void) +{ + read_replace_refs = 0; +} + +int replace_refs_enabled(struct repository *r) +{ + if (!read_replace_refs) + return 0; + + if (r->gitdir) { + prepare_repo_settings(r); + return r->settings.read_replace_refs; + } + + /* repository has no objects or refs. */ + return 0; +} |