@matheusbsbs / matheus-bagliano / commits / 64560374cc
Fork 0

Add support for "local" packing

This adds the "--local" flag to git-pack-objects, which acts like "--incremental", except that instead of ignoring all packed objects, it only ignores objects that are packed and in an alternate object tree. As a result, it effectively only does a local re-pack: any remote-packed objects will stay in the alternate object directories. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Oct 13, 2005 at 15:38 UTC 64560374cc6c3ebe595540f3425b2b38036cf253
1 file changed +21 -3
pack-objects.c
+21 -3
@@ -5,7 +5,7 @@
5 #include "pack.h"
6 #include "csum-file.h"
7
8 -static const char pack_usage[] = "git-pack-objects [--incremental] [--window=N] [--depth=N] {--stdout | base-name} < object-list";
8 +static const char pack_usage[] = "git-pack-objects [--local] [--incremental] [--window=N] [--depth=N] {--stdout | base-name} < object-list";
9
10 struct object_entry {
11 unsigned char sha1[20];
@@ -20,6 +20,7 @@ struct object_entry {
20
21 static unsigned char object_list_sha1[20];
22 static int non_empty = 0;
23 +static int local = 0;
24 static int incremental = 0;
25 static struct object_entry **sorted_by_sha, **sorted_by_type;
26 static struct object_entry *objects = NULL;
@@ -195,8 +196,20 @@ static int add_object_entry(unsigned char *sha1, unsigned int hash)
196 unsigned int idx = nr_objects;
197 struct object_entry *entry;
198
198 - if (incremental && has_sha1_pack(sha1))
199 - return 0;
199 + if (incremental || local) {
200 + struct packed_git *p;
201 +
202 + for (p = packed_git; p; p = p->next) {
203 + struct pack_entry e;
204 +
205 + if (find_pack_entry_one(sha1, &e, p)) {
206 + if (incremental)
207 + return 0;
208 + if (local && !p->pack_local)
209 + return 0;
210 + }
211 + }
212 + }
213
214 if (idx >= nr_alloc) {
215 unsigned int needed = (idx + 1024) * 3 / 2;
@@ -404,6 +417,10 @@ int main(int argc, char **argv)
417 non_empty = 1;
418 continue;
419 }
420 + if (!strcmp("--local", arg)) {
421 + local = 1;
422 + continue;
423 + }
424 if (!strcmp("--incremental", arg)) {
425 incremental = 1;
426 continue;
@@ -436,6 +453,7 @@ int main(int argc, char **argv)
453 if (pack_to_stdout != !base_name)
454 usage(pack_usage);
455
456 + prepare_packed_git();
457 while (fgets(line, sizeof(line), stdin) != NULL) {
458 unsigned int hash;
459 char *p;