upload-pack: move shallow deepen code out of receive_needs()
This is a prep step for further refactoring. Besides reindentation and s/shallows\./shallows->/g, no other changes are expected. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
9318c5dd14
commit
e8e44de787
@ -538,6 +538,55 @@ error:
|
||||
}
|
||||
}
|
||||
|
||||
static void deepen(int depth, const struct object_array *shallows)
|
||||
{
|
||||
struct commit_list *result = NULL, *backup = NULL;
|
||||
int i;
|
||||
if (depth == INFINITE_DEPTH && !is_repository_shallow())
|
||||
for (i = 0; i < shallows->nr; i++) {
|
||||
struct object *object = shallows->objects[i].item;
|
||||
object->flags |= NOT_SHALLOW;
|
||||
}
|
||||
else
|
||||
backup = result =
|
||||
get_shallow_commits(&want_obj, depth,
|
||||
SHALLOW, NOT_SHALLOW);
|
||||
while (result) {
|
||||
struct object *object = &result->item->object;
|
||||
if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
|
||||
packet_write(1, "shallow %s",
|
||||
oid_to_hex(&object->oid));
|
||||
register_shallow(object->oid.hash);
|
||||
shallow_nr++;
|
||||
}
|
||||
result = result->next;
|
||||
}
|
||||
free_commit_list(backup);
|
||||
for (i = 0; i < shallows->nr; i++) {
|
||||
struct object *object = shallows->objects[i].item;
|
||||
if (object->flags & NOT_SHALLOW) {
|
||||
struct commit_list *parents;
|
||||
packet_write(1, "unshallow %s",
|
||||
oid_to_hex(&object->oid));
|
||||
object->flags &= ~CLIENT_SHALLOW;
|
||||
/* make sure the real parents are parsed */
|
||||
unregister_shallow(object->oid.hash);
|
||||
object->parsed = 0;
|
||||
parse_commit_or_die((struct commit *)object);
|
||||
parents = ((struct commit *)object)->parents;
|
||||
while (parents) {
|
||||
add_object_array(&parents->item->object,
|
||||
NULL, &want_obj);
|
||||
parents = parents->next;
|
||||
}
|
||||
add_object_array(object, NULL, &extra_edge_obj);
|
||||
}
|
||||
/* make sure commit traversal conforms to client */
|
||||
register_shallow(object->oid.hash);
|
||||
}
|
||||
packet_flush(1);
|
||||
}
|
||||
|
||||
static void receive_needs(void)
|
||||
{
|
||||
struct object_array shallows = OBJECT_ARRAY_INIT;
|
||||
@ -630,53 +679,9 @@ static void receive_needs(void)
|
||||
|
||||
if (depth == 0 && shallows.nr == 0)
|
||||
return;
|
||||
if (depth > 0) {
|
||||
struct commit_list *result = NULL, *backup = NULL;
|
||||
int i;
|
||||
if (depth == INFINITE_DEPTH && !is_repository_shallow())
|
||||
for (i = 0; i < shallows.nr; i++) {
|
||||
struct object *object = shallows.objects[i].item;
|
||||
object->flags |= NOT_SHALLOW;
|
||||
}
|
||||
else
|
||||
backup = result =
|
||||
get_shallow_commits(&want_obj, depth,
|
||||
SHALLOW, NOT_SHALLOW);
|
||||
while (result) {
|
||||
struct object *object = &result->item->object;
|
||||
if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
|
||||
packet_write(1, "shallow %s",
|
||||
oid_to_hex(&object->oid));
|
||||
register_shallow(object->oid.hash);
|
||||
shallow_nr++;
|
||||
}
|
||||
result = result->next;
|
||||
}
|
||||
free_commit_list(backup);
|
||||
for (i = 0; i < shallows.nr; i++) {
|
||||
struct object *object = shallows.objects[i].item;
|
||||
if (object->flags & NOT_SHALLOW) {
|
||||
struct commit_list *parents;
|
||||
packet_write(1, "unshallow %s",
|
||||
oid_to_hex(&object->oid));
|
||||
object->flags &= ~CLIENT_SHALLOW;
|
||||
/* make sure the real parents are parsed */
|
||||
unregister_shallow(object->oid.hash);
|
||||
object->parsed = 0;
|
||||
parse_commit_or_die((struct commit *)object);
|
||||
parents = ((struct commit *)object)->parents;
|
||||
while (parents) {
|
||||
add_object_array(&parents->item->object,
|
||||
NULL, &want_obj);
|
||||
parents = parents->next;
|
||||
}
|
||||
add_object_array(object, NULL, &extra_edge_obj);
|
||||
}
|
||||
/* make sure commit traversal conforms to client */
|
||||
register_shallow(object->oid.hash);
|
||||
}
|
||||
packet_flush(1);
|
||||
} else
|
||||
if (depth > 0)
|
||||
deepen(depth, &shallows);
|
||||
else
|
||||
if (shallows.nr > 0) {
|
||||
int i;
|
||||
for (i = 0; i < shallows.nr; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user