upload-pack: move "shallow" sending code out of deepen()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Jun 12, 2016 at 17:53 UTC
5c24cdea1e33c72bfed4af25a363eb5ceae11199
1 file changed
+15
-10
upload-pack.c
+15
-10
@@ -538,6 +538,20 @@ error:
538
}
539
}
540
541
+static void send_shallow(struct commit_list *result)
542
+{
543
+ while (result) {
544
+ struct object *object = &result->item->object;
545
+ if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
546
+ packet_write(1, "shallow %s",
547
+ oid_to_hex(&object->oid));
548
+ register_shallow(object->oid.hash);
549
+ shallow_nr++;
550
+ }
551
+ result = result->next;
552
+ }
553
+}
554
+
555
static void deepen(int depth, const struct object_array *shallows)
556
{
557
struct commit_list *result = NULL, *backup = NULL;
@@ -551,16 +565,7 @@ static void deepen(int depth, const struct object_array *shallows)
565
backup = result =
566
get_shallow_commits(&want_obj, depth,
567
SHALLOW, NOT_SHALLOW);
554
- while (result) {
555
- struct object *object = &result->item->object;
556
- if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
557
- packet_write(1, "shallow %s",
558
- oid_to_hex(&object->oid));
559
- register_shallow(object->oid.hash);
560
- shallow_nr++;
561
- }
562
- result = result->next;
563
- }
568
+ send_shallow(result);
569
free_commit_list(backup);
570
for (i = 0; i < shallows->nr; i++) {
571
struct object *object = shallows->objects[i].item;