summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-03 20:08:40 (GMT)
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-03 20:08:40 (GMT)
commiteb019375abf545ec644e043f830ab573c2a4cd74 (patch)
treea0f02829ce9b92519869041beceaf65e3c1a1780
parent960bba0d8c14c9eb76bbb42eebc39eff58fc452b (diff)
downloadgit-eb019375abf545ec644e043f830ab573c2a4cd74.zip
git-eb019375abf545ec644e043f830ab573c2a4cd74.tar.gz
git-eb019375abf545ec644e043f830ab573c2a4cd74.tar.bz2
Add "--incremental" flag to git-pack-objects
It won't add an object that is already in a pack to the new pack.
-rw-r--r--pack-objects.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/pack-objects.c b/pack-objects.c
index d95f45e..780418d 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -5,7 +5,7 @@
#include "pack.h"
#include "csum-file.h"
-static const char pack_usage[] = "git-pack-objects [--window=N] [--depth=N] {--stdout | base-name} < object-list";
+static const char pack_usage[] = "git-pack-objects [--incremental] [--window=N] [--depth=N] {--stdout | base-name} < object-list";
struct object_entry {
unsigned char sha1[20];
@@ -18,6 +18,7 @@ struct object_entry {
struct object_entry *delta;
};
+static int incremental = 0;
static struct object_entry **sorted_by_sha, **sorted_by_type;
static struct object_entry *objects = NULL;
static int nr_objects = 0, nr_alloc = 0;
@@ -192,6 +193,9 @@ static void add_object_entry(unsigned char *sha1, unsigned int hash)
unsigned int idx = nr_objects;
struct object_entry *entry;
+ if (incremental && has_sha1_pack(sha1))
+ return;
+
if (idx >= nr_alloc) {
unsigned int needed = (idx + 1024) * 3 / 2;
objects = xrealloc(objects, needed * sizeof(*entry));
@@ -387,6 +391,10 @@ int main(int argc, char **argv)
const char *arg = argv[i];
if (*arg == '-') {
+ if (!strcmp("--incremental", arg)) {
+ incremental = 1;
+ continue;
+ }
if (!strncmp("--window=", arg, 9)) {
char *end;
window = strtoul(arg+9, &end, 0);