replace-object: add repository argument to prepare_replace_object
[git/git.git] / replace-object.h
CommitLineData
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
d88f9fdf
SB
8struct replace_object {
9 struct oidmap_entry original;
10 struct object_id replacement;
11};
12
47f351e9
SB
13/*
14 * This internal function is only declared here for the benefit of
15 * lookup_replace_object(). Please do not call it directly.
16 */
17extern const struct object_id *do_lookup_replace_object(const struct object_id *oid);
18
19/*
20 * If object sha1 should be replaced, return the replacement object's
21 * name (replaced recursively, if necessary). The return value is
22 * either sha1 or a pointer to a permanently-allocated value. When
23 * object replacement is suppressed, always return sha1.
24 */
25static inline const struct object_id *lookup_replace_object(const struct object_id *oid)
26{
c3c36d7d
SB
27 if (!check_replace_refs ||
28 (the_repository->objects->replace_map &&
29 the_repository->objects->replace_map->map.tablesize == 0))
47f351e9
SB
30 return oid;
31 return do_lookup_replace_object(oid);
32}
33
d88f9fdf 34#endif /* REPLACE_OBJECT_H */