From: Shawn O. Pearce Date: Wed, 23 Aug 2006 06:00:31 +0000 (-0400) Subject: Converted fast-import to accept standard command line parameters. X-Git-Tag: v1.5.0-rc4~14^2~70 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d5c57b284e847a56cc1d98b783be95ba94285afe;p=git.git 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 --- 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);