Skip to content

Commit

Permalink
Add "--non-empty" flag to git-pack-objects
Browse files Browse the repository at this point in the history
It skips writing the pack-file if it ends up being empty.
  • Loading branch information
Linus Torvalds committed Jul 3, 2005
1 parent 12d2a18 commit 1c4a291
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct object_entry {
struct object_entry *delta;
};

static int non_empty = 0;
static int incremental = 0;
static struct object_entry **sorted_by_sha, **sorted_by_type;
static struct object_entry *objects = NULL;
Expand Down Expand Up @@ -391,6 +392,10 @@ int main(int argc, char **argv)
const char *arg = argv[i];

if (*arg == '-') {
if (!strcmp("--non-empty", arg)) {
non_empty = 1;
continue;
}
if (!strcmp("--incremental", arg)) {
incremental = 1;
continue;
Expand Down Expand Up @@ -440,6 +445,8 @@ int main(int argc, char **argv)
}
add_object_entry(sha1, hash);
}
if (non_empty && !nr_objects)
return 0;
get_object_details();

fprintf(stderr, "Packing %d objects\n", nr_objects);
Expand Down

0 comments on commit 1c4a291

Please sign in to comment.