Skip to content

Commit

Permalink
Add "--incremental" flag to git-pack-objects
Browse files Browse the repository at this point in the history
It won't add an object that is already in a pack to the new pack.
  • Loading branch information
Linus Torvalds committed Jul 3, 2005
1 parent 960bba0 commit eb01937
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit eb01937

Please sign in to comment.