aboutsummaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2006-08-23 02:00:31 -0400
committerShawn O. Pearce <spearce@spearce.org>2007-01-14 02:15:05 -0500
commitd5c57b284e847a56cc1d98b783be95ba94285afe (patch)
tree92535e41537a610c752c7b71afc985de99f6ec17 /fast-import.c
parentafde8dd96dbb81688d7cb22330e4fffcfc7def21 (diff)
downloadgit-d5c57b284e847a56cc1d98b783be95ba94285afe.tar.gz
git-d5c57b284e847a56cc1d98b783be95ba94285afe.tar.xz
Converted fast-import to accept standard command line parameters.
The following command line options are now accepted before the pack name: --objects=n # replaces the object count after the pack name --depth=n # delta chain depth to use (default is 10) --active-branches=n # maximum number of branches to keep in memory Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/fast-import.c b/fast-import.c
index 4c2431f0b..859849365 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -178,7 +178,7 @@ struct branch
/* Stats and misc. counters */
-static int max_depth = 10;
+static unsigned long max_depth = 10;
static unsigned long alloc_count;
static unsigned long branch_count;
static unsigned long object_count;
@@ -216,9 +216,9 @@ static unsigned int avail_tree_table_sz = 100;
static struct avail_tree_content **avail_tree_table;
/* Branch data */
-static unsigned int max_active_branches = 5;
-static unsigned int cur_active_branches;
-static unsigned int branch_table_sz = 1039;
+static unsigned long max_active_branches = 5;
+static unsigned long cur_active_branches;
+static unsigned long branch_table_sz = 1039;
static struct branch **branch_table;
static struct branch *active_branches;
@@ -1236,10 +1236,14 @@ static void cmd_new_branch()
die("An lf did not terminate the branch command as expected.");
}
+static const char fast_import_usage[] =
+"git-fast-import [--objects=n] [--depth=n] [--active-branches=n] temp.pack";
+
int main(int argc, const char **argv)
{
- const char *base_name = argv[1];
- int est_obj_cnt = atoi(argv[2]);
+ const char *base_name;
+ int i;
+ unsigned long est_obj_cnt = 1000;
char *pack_name;
char *idx_name;
struct stat sb;
@@ -1247,6 +1251,24 @@ int main(int argc, const char **argv)
setup_ident();
git_config(git_default_config);
+ for (i = 1; i < argc; i++) {
+ const char *a = argv[i];
+
+ if (*a != '-' || !strcmp(a, "--"))
+ break;
+ else if (!strncmp(a, "--objects=", 10))
+ est_obj_cnt = strtoul(a + 10, NULL, 0);
+ else if (!strncmp(a, "--depth=", 8))
+ max_depth = strtoul(a + 8, NULL, 0);
+ else if (!strncmp(a, "--active-branches=", 18))
+ max_active_branches = strtoul(a + 18, NULL, 0);
+ else
+ die("unknown option %s", a);
+ }
+ if ((i+1) != argc)
+ usage(fast_import_usage);
+ base_name = argv[i];
+
pack_name = xmalloc(strlen(base_name) + 6);
sprintf(pack_name, "%s.pack", base_name);
idx_name = xmalloc(strlen(base_name) + 5);