]>
Commit | Line | Data |
---|---|---|
d88f9fdf SB |
1 | #ifndef REPLACE_OBJECT_H |
2 | #define REPLACE_OBJECT_H | |
3 | ||
47f351e9 SB |
4 | #include "oidmap.h" |
5 | #include "repository.h" | |
c3c36d7d | 6 | #include "object-store.h" |
47f351e9 | 7 | |
cbeab747 EN |
8 | /* |
9 | * Do replace refs need to be checked this run? This variable is | |
10 | * initialized to true unless --no-replace-object is used or | |
11 | * $GIT_NO_REPLACE_OBJECTS is set, but is set to false by some | |
12 | * commands that do not want replace references to be active. | |
13 | */ | |
14 | extern int read_replace_refs; | |
15 | ||
d88f9fdf SB |
16 | struct replace_object { |
17 | struct oidmap_entry original; | |
18 | struct object_id replacement; | |
19 | }; | |
20 | ||
d6538246 DS |
21 | void prepare_replace_object(struct repository *r); |
22 | ||
47f351e9 SB |
23 | /* |
24 | * This internal function is only declared here for the benefit of | |
25 | * lookup_replace_object(). Please do not call it directly. | |
26 | */ | |
55454427 | 27 | const struct object_id *do_lookup_replace_object(struct repository *r, |
ad6dad09 | 28 | const struct object_id *oid); |
47f351e9 SB |
29 | |
30 | /* | |
31 | * If object sha1 should be replaced, return the replacement object's | |
32 | * name (replaced recursively, if necessary). The return value is | |
33 | * either sha1 or a pointer to a permanently-allocated value. When | |
34 | * object replacement is suppressed, always return sha1. | |
b1fc9da1 MT |
35 | * |
36 | * Note: some thread debuggers might point a data race on the | |
37 | * replace_map_initialized reading in this function. However, we know there's no | |
38 | * problem in the value being updated by one thread right after another one read | |
39 | * it here (and it should be written to only once, anyway). | |
47f351e9 | 40 | */ |
90e777f1 SB |
41 | static inline const struct object_id *lookup_replace_object(struct repository *r, |
42 | const struct object_id *oid) | |
47f351e9 | 43 | { |
6ebd1caf | 44 | if (!read_replace_refs || |
b1fc9da1 | 45 | (r->objects->replace_map_initialized && |
90e777f1 | 46 | r->objects->replace_map->map.tablesize == 0)) |
47f351e9 | 47 | return oid; |
90e777f1 | 48 | return do_lookup_replace_object(r, oid); |
47f351e9 SB |
49 | } |
50 | ||
d88f9fdf | 51 | #endif /* REPLACE_OBJECT_H */ |