Merge branch 'ss/pull-rebase-preserve' into maint
[gitweb.git] / replace_object.c
index 6fc3ff47b14740d7a1a31ada23ac1f9c940d4acb..0ab2dc137487259d50b69258e967792aa6c43619 100644 (file)
@@ -41,12 +41,8 @@ static int register_replace_object(struct replace_object *replace,
                return 1;
        }
        pos = -pos - 1;
-       if (replace_object_alloc <= ++replace_object_nr) {
-               replace_object_alloc = alloc_nr(replace_object_alloc);
-               replace_object = xrealloc(replace_object,
-                                         sizeof(*replace_object) *
-                                         replace_object_alloc);
-       }
+       ALLOC_GROW(replace_object, replace_object_nr + 1, replace_object_alloc);
+       replace_object_nr++;
        if (pos < replace_object_nr)
                memmove(replace_object + pos + 1,
                        replace_object + pos,
@@ -91,12 +87,19 @@ static void prepare_replace_object(void)
        for_each_replace_ref(register_replace_ref, NULL);
        replace_object_prepared = 1;
        if (!replace_object_nr)
-               read_replace_refs = 0;
+               check_replace_refs = 0;
 }
 
 /* We allow "recursive" replacement. Only within reason, though */
 #define MAXREPLACEDEPTH 5
 
+/*
+ * If a replacement for object sha1 has been set up, return the
+ * replacement object's name (replaced recursively, if necessary).
+ * The return value is either sha1 or a pointer to a
+ * permanently-allocated value.  This function always respects replace
+ * references, regardless of the value of check_replace_refs.
+ */
 const unsigned char *do_lookup_replace_object(const unsigned char *sha1)
 {
        int pos, depth = MAXREPLACEDEPTH;