Add docstrings for lookup_replace_object() and do_lookup_replace_object()
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Feb 28, 2014 at 17:29 UTC
1f91e79cf61eaa7cb26eb0aa1e257b7681c4c328
2 files changed
+20
cache.h
+13
@@ -798,13 +798,26 @@ static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *
798
{
799
return read_sha1_file_extended(sha1, type, size, LOOKUP_REPLACE_OBJECT);
800
}
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
+ */
806
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
+ */
814
static inline const unsigned char *lookup_replace_object(const unsigned char *sha1)
815
{
816
if (!check_replace_refs)
817
return sha1;
818
return do_lookup_replace_object(sha1);
819
}
820
+
821
static inline const unsigned char *lookup_replace_object_extended(const unsigned char *sha1, unsigned flag)
822
{
823
if (!(flag & LOOKUP_REPLACE_OBJECT))
replace_object.c
+7
@@ -92,6 +92,13 @@ static void prepare_replace_object(void)
92
/* We allow "recursive" replacement. Only within reason, though */
93
#define MAXREPLACEDEPTH 5
94
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
+ */
102
const unsigned char *do_lookup_replace_object(const unsigned char *sha1)
103
{
104
int pos, depth = MAXREPLACEDEPTH;