summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-03 20:36:58 (GMT)
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-03 20:36:58 (GMT)
commit1c4a29120240a35b9c02afa636dac3e55ac96cb0 (patch)
tree6b5c4dbb16e8da8019724362f570882afc92ba95
parent12d2a18780321e0d00a0656f4965716ada910f66 (diff)
downloadgit-1c4a29120240a35b9c02afa636dac3e55ac96cb0.zip
git-1c4a29120240a35b9c02afa636dac3e55ac96cb0.tar.gz
git-1c4a29120240a35b9c02afa636dac3e55ac96cb0.tar.bz2
Add "--non-empty" flag to git-pack-objects
It skips writing the pack-file if it ends up being empty.
-rw-r--r--pack-objects.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/pack-objects.c b/pack-objects.c
index 780418d..9e9c578 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -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;
@@ -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;
@@ -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);