@matheusbsbs / matheus-bagliano / commits / d5c57b284e
Fork 0

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>

Shawn O. Pearce committed Aug 23, 2006 at 02:00 UTC d5c57b284e847a56cc1d98b783be95ba94285afe
1 file changed +28 -6
fast-import.c
+28 -6
@@ -178,7 +178,7 @@ struct branch
178
179
180 /* Stats and misc. counters */
181 -static int max_depth = 10;
181 +static unsigned long max_depth = 10;
182 static unsigned long alloc_count;
183 static unsigned long branch_count;
184 static unsigned long object_count;
@@ -216,9 +216,9 @@ static unsigned int avail_tree_table_sz = 100;
216 static struct avail_tree_content **avail_tree_table;
217
218 /* Branch data */
219 -static unsigned int max_active_branches = 5;
220 -static unsigned int cur_active_branches;
221 -static unsigned int branch_table_sz = 1039;
219 +static unsigned long max_active_branches = 5;
220 +static unsigned long cur_active_branches;
221 +static unsigned long branch_table_sz = 1039;
222 static struct branch **branch_table;
223 static struct branch *active_branches;
224
@@ -1236,10 +1236,14 @@ static void cmd_new_branch()
1236 die("An lf did not terminate the branch command as expected.");
1237 }
1238
1239 +static const char fast_import_usage[] =
1240 +"git-fast-import [--objects=n] [--depth=n] [--active-branches=n] temp.pack";
1241 +
1242 int main(int argc, const char **argv)
1243 {
1241 - const char *base_name = argv[1];
1242 - int est_obj_cnt = atoi(argv[2]);
1244 + const char *base_name;
1245 + int i;
1246 + unsigned long est_obj_cnt = 1000;
1247 char *pack_name;
1248 char *idx_name;
1249 struct stat sb;
@@ -1247,6 +1251,24 @@ int main(int argc, const char **argv)
1251 setup_ident();
1252 git_config(git_default_config);
1253
1254 + for (i = 1; i < argc; i++) {
1255 + const char *a = argv[i];
1256 +
1257 + if (*a != '-' || !strcmp(a, "--"))
1258 + break;
1259 + else if (!strncmp(a, "--objects=", 10))
1260 + est_obj_cnt = strtoul(a + 10, NULL, 0);
1261 + else if (!strncmp(a, "--depth=", 8))
1262 + max_depth = strtoul(a + 8, NULL, 0);
1263 + else if (!strncmp(a, "--active-branches=", 18))
1264 + max_active_branches = strtoul(a + 18, NULL, 0);
1265 + else
1266 + die("unknown option %s", a);
1267 + }
1268 + if ((i+1) != argc)
1269 + usage(fast_import_usage);
1270 + base_name = argv[i];
1271 +
1272 pack_name = xmalloc(strlen(base_name) + 6);
1273 sprintf(pack_name, "%s.pack", base_name);
1274 idx_name = xmalloc(strlen(base_name) + 5);