summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-09-07 22:23:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-09-07 22:23:50 (GMT)
commit8e4384fd4438a143af7125eb0f03312a318319fb (patch)
tree291180389c88c849627dc1f0181c9b8cc87b5a02
parent6ea71fe7d36cf5b81c2100d97a822ecf0bc04746 (diff)
parent0ef95f72f878184fbce8d7c855ab4346c081abed (diff)
downloadgit-8e4384fd4438a143af7125eb0f03312a318319fb.zip
git-8e4384fd4438a143af7125eb0f03312a318319fb.tar.gz
git-8e4384fd4438a143af7125eb0f03312a318319fb.tar.bz2
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
-rw-r--r--builtin-pack-objects.c28
-rw-r--r--upload-pack.c8
2 files changed, 34 insertions, 2 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 1ff2ce6..7a390e1 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1008,6 +1008,33 @@ static void add_preferred_base(unsigned char *sha1)
it->pcache.tree_size = size;
}
+static void cleanup_preferred_base(void)
+{
+ struct pbase_tree *it;
+ unsigned i;
+
+ it = pbase_tree;
+ pbase_tree = NULL;
+ while (it) {
+ struct pbase_tree *this = it;
+ it = this->next;
+ free(this->pcache.tree_data);
+ free(this);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(pbase_tree_cache); i++) {
+ if (!pbase_tree_cache[i])
+ continue;
+ free(pbase_tree_cache[i]->tree_data);
+ free(pbase_tree_cache[i]);
+ pbase_tree_cache[i] = NULL;
+ }
+
+ free(done_pbase_paths);
+ done_pbase_paths = NULL;
+ done_pbase_paths_num = done_pbase_paths_alloc = 0;
+}
+
static void check_object(struct object_entry *entry)
{
if (entry->in_pack) {
@@ -2312,6 +2339,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
rp_av[rp_ac] = NULL;
get_object_list(rp_ac, rp_av);
}
+ cleanup_preferred_base();
if (include_tag && nr_result)
for_each_ref(add_ref_tag, NULL);
stop_progress(&progress_state);
diff --git a/upload-pack.c b/upload-pack.c
index dacbc76..25e222f 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -32,6 +32,7 @@ static int no_progress, daemon_mode;
static int shallow_nr;
static struct object_array have_obj;
static struct object_array want_obj;
+static struct object_array extra_edge_obj;
static unsigned int timeout;
/* 0 for no sideband,
* otherwise maximum packet size (up to 65520 bytes).
@@ -135,6 +136,10 @@ static int do_rev_list(int fd, void *create_full_pack)
if (prepare_revision_walk(&revs))
die("revision walk setup failed");
mark_edges_uninteresting(revs.commits, &revs, show_edge);
+ if (use_thin_pack)
+ for (i = 0; i < extra_edge_obj.nr; i++)
+ fprintf(pack_pipe, "-%s\n", sha1_to_hex(
+ extra_edge_obj.objects[i].item->sha1));
traverse_commit_list(&revs, show_commit, show_object, NULL);
fflush(pack_pipe);
fclose(pack_pipe);
@@ -492,7 +497,6 @@ static void receive_needs(void)
if (!prefixcmp(line, "shallow ")) {
unsigned char sha1[20];
struct object *object;
- use_thin_pack = 0;
if (get_sha1(line + 8, sha1))
die("invalid shallow line: %s", line);
object = parse_object(sha1);
@@ -504,7 +508,6 @@ static void receive_needs(void)
}
if (!prefixcmp(line, "deepen ")) {
char *end;
- use_thin_pack = 0;
depth = strtol(line + 7, &end, 0);
if (end == line + 7 || depth <= 0)
die("Invalid deepen: %s", line);
@@ -587,6 +590,7 @@ static void receive_needs(void)
NULL, &want_obj);
parents = parents->next;
}
+ add_object_array(object, NULL, &extra_edge_obj);
}
/* make sure commit traversal conforms to client */
register_shallow(object->sha1);