Skip to content

Commit 47f351e

Browse files
stefanbellergitster
authored andcommitted
object-store: move lookup_replace_object to replace-object.h
lookup_replace_object is a low-level function that most users of the object store do not need to use directly. Move it to replace-object.h to avoid a dependency loop in an upcoming change to its inline definition that will make use of repository.h. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d88f9fd commit 47f351e

File tree

6 files changed

+26
-19
lines changed

6 files changed

+26
-19
lines changed

builtin/mktag.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "builtin.h"
22
#include "tag.h"
3+
#include "replace-object.h"
34

45
/*
56
* A signature file has a very simple fixed format: four lines

cache.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,25 +1191,6 @@ static inline void *read_object_file(const struct object_id *oid, enum object_ty
11911191
return read_object_file_extended(oid, type, size, 1);
11921192
}
11931193

1194-
/*
1195-
* This internal function is only declared here for the benefit of
1196-
* lookup_replace_object(). Please do not call it directly.
1197-
*/
1198-
extern const struct object_id *do_lookup_replace_object(const struct object_id *oid);
1199-
1200-
/*
1201-
* If object sha1 should be replaced, return the replacement object's
1202-
* name (replaced recursively, if necessary). The return value is
1203-
* either sha1 or a pointer to a permanently-allocated value. When
1204-
* object replacement is suppressed, always return sha1.
1205-
*/
1206-
static inline const struct object_id *lookup_replace_object(const struct object_id *oid)
1207-
{
1208-
if (!check_replace_refs)
1209-
return oid;
1210-
return do_lookup_replace_object(oid);
1211-
}
1212-
12131194
/* Read and unpack an object file into memory, write memory to an object file */
12141195
extern int oid_object_info(const struct object_id *, unsigned long *);
12151196

object.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "cache.h"
22
#include "object.h"
3+
#include "replace-object.h"
34
#include "blob.h"
45
#include "tree.h"
56
#include "commit.h"

replace-object.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
#ifndef REPLACE_OBJECT_H
22
#define REPLACE_OBJECT_H
33

4+
#include "oidmap.h"
5+
#include "repository.h"
6+
47
struct replace_object {
58
struct oidmap_entry original;
69
struct object_id replacement;
710
};
811

12+
/*
13+
* This internal function is only declared here for the benefit of
14+
* lookup_replace_object(). Please do not call it directly.
15+
*/
16+
extern const struct object_id *do_lookup_replace_object(const struct object_id *oid);
17+
18+
/*
19+
* If object sha1 should be replaced, return the replacement object's
20+
* name (replaced recursively, if necessary). The return value is
21+
* either sha1 or a pointer to a permanently-allocated value. When
22+
* object replacement is suppressed, always return sha1.
23+
*/
24+
static inline const struct object_id *lookup_replace_object(const struct object_id *oid)
25+
{
26+
if (!check_replace_refs)
27+
return oid;
28+
return do_lookup_replace_object(oid);
29+
}
30+
931
#endif /* REPLACE_OBJECT_H */

sha1_file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "sha1-lookup.h"
2424
#include "bulk-checkin.h"
2525
#include "repository.h"
26+
#include "replace-object.h"
2627
#include "streaming.h"
2728
#include "dir.h"
2829
#include "list.h"

streaming.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "streaming.h"
66
#include "repository.h"
77
#include "object-store.h"
8+
#include "replace-object.h"
89
#include "packfile.h"
910

1011
enum input_source {

0 commit comments

Comments
 (0)