]>
Commit | Line | Data |
---|---|---|
1 | #ifndef REPLACE_OBJECT_H | |
2 | #define REPLACE_OBJECT_H | |
3 | ||
4 | #include "oidmap.h" | |
5 | #include "repository.h" | |
6 | #include "object-store.h" | |
7 | ||
8 | struct replace_object { | |
9 | struct oidmap_entry original; | |
10 | struct object_id replacement; | |
11 | }; | |
12 | ||
13 | void prepare_replace_object(struct repository *r); | |
14 | ||
15 | /* | |
16 | * This internal function is only declared here for the benefit of | |
17 | * lookup_replace_object(). Please do not call it directly. | |
18 | */ | |
19 | const struct object_id *do_lookup_replace_object(struct repository *r, | |
20 | const struct object_id *oid); | |
21 | ||
22 | /* | |
23 | * If object sha1 should be replaced, return the replacement object's | |
24 | * name (replaced recursively, if necessary). The return value is | |
25 | * either sha1 or a pointer to a permanently-allocated value. When | |
26 | * object replacement is suppressed, always return sha1. | |
27 | * | |
28 | * Note: some thread debuggers might point a data race on the | |
29 | * replace_map_initialized reading in this function. However, we know there's no | |
30 | * problem in the value being updated by one thread right after another one read | |
31 | * it here (and it should be written to only once, anyway). | |
32 | */ | |
33 | static inline const struct object_id *lookup_replace_object(struct repository *r, | |
34 | const struct object_id *oid) | |
35 | { | |
36 | if (!read_replace_refs || | |
37 | (r->objects->replace_map_initialized && | |
38 | r->objects->replace_map->map.tablesize == 0)) | |
39 | return oid; | |
40 | return do_lookup_replace_object(r, oid); | |
41 | } | |
42 | ||
43 | #endif /* REPLACE_OBJECT_H */ |