Skip to content

Commit 1f91e79

Browse files
mhaggergitster
authored andcommitted
Add docstrings for lookup_replace_object() and do_lookup_replace_object()
Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent afc711b commit 1f91e79

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

cache.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,13 +798,26 @@ static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *
798798
{
799799
return read_sha1_file_extended(sha1, type, size, LOOKUP_REPLACE_OBJECT);
800800
}
801+
802+
/*
803+
* This internal function is only declared here for the benefit of
804+
* lookup_replace_object(). Please do not call it directly.
805+
*/
801806
extern const unsigned char *do_lookup_replace_object(const unsigned char *sha1);
807+
808+
/*
809+
* If object sha1 should be replaced, return the replacement object's
810+
* name (replaced recursively, if necessary). The return value is
811+
* either sha1 or a pointer to a permanently-allocated value. When
812+
* object replacement is suppressed, always return sha1.
813+
*/
802814
static inline const unsigned char *lookup_replace_object(const unsigned char *sha1)
803815
{
804816
if (!check_replace_refs)
805817
return sha1;
806818
return do_lookup_replace_object(sha1);
807819
}
820+
808821
static inline const unsigned char *lookup_replace_object_extended(const unsigned char *sha1, unsigned flag)
809822
{
810823
if (!(flag & LOOKUP_REPLACE_OBJECT))

replace_object.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ static void prepare_replace_object(void)
9292
/* We allow "recursive" replacement. Only within reason, though */
9393
#define MAXREPLACEDEPTH 5
9494

95+
/*
96+
* If a replacement for object sha1 has been set up, return the
97+
* replacement object's name (replaced recursively, if necessary).
98+
* The return value is either sha1 or a pointer to a
99+
* permanently-allocated value. This function always respects replace
100+
* references, regardless of the value of check_replace_refs.
101+
*/
95102
const unsigned char *do_lookup_replace_object(const unsigned char *sha1)
96103
{
97104
int pos, depth = MAXREPLACEDEPTH;

0 commit comments

Comments
 (0)