Skip to content

Commit 8e4384f

Browse files
committed
Merge branch 'np/maint-1.6.3-deepen'
* np/maint-1.6.3-deepen: pack-objects: free preferred base memory after usage make shallow repository deepening more network efficient
2 parents 6ea71fe + 0ef95f7 commit 8e4384f

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

builtin-pack-objects.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,33 @@ static void add_preferred_base(unsigned char *sha1)
10081008
it->pcache.tree_size = size;
10091009
}
10101010

1011+
static void cleanup_preferred_base(void)
1012+
{
1013+
struct pbase_tree *it;
1014+
unsigned i;
1015+
1016+
it = pbase_tree;
1017+
pbase_tree = NULL;
1018+
while (it) {
1019+
struct pbase_tree *this = it;
1020+
it = this->next;
1021+
free(this->pcache.tree_data);
1022+
free(this);
1023+
}
1024+
1025+
for (i = 0; i < ARRAY_SIZE(pbase_tree_cache); i++) {
1026+
if (!pbase_tree_cache[i])
1027+
continue;
1028+
free(pbase_tree_cache[i]->tree_data);
1029+
free(pbase_tree_cache[i]);
1030+
pbase_tree_cache[i] = NULL;
1031+
}
1032+
1033+
free(done_pbase_paths);
1034+
done_pbase_paths = NULL;
1035+
done_pbase_paths_num = done_pbase_paths_alloc = 0;
1036+
}
1037+
10111038
static void check_object(struct object_entry *entry)
10121039
{
10131040
if (entry->in_pack) {
@@ -2312,6 +2339,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
23122339
rp_av[rp_ac] = NULL;
23132340
get_object_list(rp_ac, rp_av);
23142341
}
2342+
cleanup_preferred_base();
23152343
if (include_tag && nr_result)
23162344
for_each_ref(add_ref_tag, NULL);
23172345
stop_progress(&progress_state);

upload-pack.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static int no_progress, daemon_mode;
3232
static int shallow_nr;
3333
static struct object_array have_obj;
3434
static struct object_array want_obj;
35+
static struct object_array extra_edge_obj;
3536
static unsigned int timeout;
3637
/* 0 for no sideband,
3738
* otherwise maximum packet size (up to 65520 bytes).
@@ -135,6 +136,10 @@ static int do_rev_list(int fd, void *create_full_pack)
135136
if (prepare_revision_walk(&revs))
136137
die("revision walk setup failed");
137138
mark_edges_uninteresting(revs.commits, &revs, show_edge);
139+
if (use_thin_pack)
140+
for (i = 0; i < extra_edge_obj.nr; i++)
141+
fprintf(pack_pipe, "-%s\n", sha1_to_hex(
142+
extra_edge_obj.objects[i].item->sha1));
138143
traverse_commit_list(&revs, show_commit, show_object, NULL);
139144
fflush(pack_pipe);
140145
fclose(pack_pipe);
@@ -492,7 +497,6 @@ static void receive_needs(void)
492497
if (!prefixcmp(line, "shallow ")) {
493498
unsigned char sha1[20];
494499
struct object *object;
495-
use_thin_pack = 0;
496500
if (get_sha1(line + 8, sha1))
497501
die("invalid shallow line: %s", line);
498502
object = parse_object(sha1);
@@ -504,7 +508,6 @@ static void receive_needs(void)
504508
}
505509
if (!prefixcmp(line, "deepen ")) {
506510
char *end;
507-
use_thin_pack = 0;
508511
depth = strtol(line + 7, &end, 0);
509512
if (end == line + 7 || depth <= 0)
510513
die("Invalid deepen: %s", line);
@@ -587,6 +590,7 @@ static void receive_needs(void)
587590
NULL, &want_obj);
588591
parents = parents->next;
589592
}
593+
add_object_array(object, NULL, &extra_edge_obj);
590594
}
591595
/* make sure commit traversal conforms to client */
592596
register_shallow(object->sha1);

0 commit comments

Comments
 (0)