{"thread":{"id":"20342","subject":"option directive to fast-import","startedAt":"2009-08-02T01:29:10Z","lastAt":"2009-08-03T04:31:54Z","messageCount":8,"participants":["Sverre Rabbelier","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"119364","messageId":"fabb9a1e0908011829j3843c132ka5081d994aad973f@mail.gmail.com","threadId":"20342","inReplyTo":null,"subject":"option directive to fast-import","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-08-02T01:29:10Z","receivedAt":"2009-08-02T01:29:10Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nWhat would you think of a 'option' directive to fast-import?\n\n'option' SP <option> SP <value> LF\n\nWhere <option> is:\n\nimport-marks\nexport-marks\nforce_update\nquiet\nstats\ndate-format\ndepth\nactive-branches\nexport-pack-edges\n\nI just checked them all, and as far as I can see, as long as the\noption directives come before any data, there should be no negative\nside-effects to setting these values 'late'. The upside would be that\nthe frontend can tell git fast-import it's preferences, so that the\nuser does not have to type a humongous commandline, but instead can\nsuffice to just go with 'foo fast-export | git fast-import'. Of\ncourse, the user might want to override these options manually, so the\noption directives should only be honored if no commandline flag is\ngiven.\n\nWould you accept such a patch? If yes, I'll whip something up :).\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"119371","messageId":"1249189570-26576-1-git-send-email-srabbelier@gmail.com","threadId":"20342","inReplyTo":"fabb9a1e0908011829j3843c132ka5081d994aad973f@mail.gmail.com","subject":"[RFC PATCH 0/3] fast-import: add option command","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-08-02T05:06:07Z","receivedAt":"2009-08-02T05:06:07Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Because I am too impatient to wait for a reply to my earlier mail,\nhere is an RFC series that demonstrates how I envision the option\ncommand to work.\n\n>From the second patch:\n\n    This allows the frontend to specify any of the supported options as\n    long as no non-option command has been given. This way the\n    user does not have to include any frontend-specific options, but\n    instead she can rely on the frontend to tell fast-import what it\n    needs.\n\nThis change of course means that old fast-import clients will break\nupon receiving an 'option' command (or with an argument they don't\nsupport), but such clients will break with a clear output stating\nthe reason for the breakage. Newer frontends therefore should only\noutput options if the user tells them to (by means of a flag/config\noption), or at least allow disabling option output.\n\nThe main use case for this is hg-git, which I want to modify so that\nit uses 'hg fast-export | git fast-import' for the intial import.\nHowever, to do that I need the fast-import part to write a marks\nfile, that is, --write-marks=git.marks. To simplify this process for\nthe user, it would be nice if 'hg fast-export' can instead emit an\n'option write-marks git.marks' line (hence the test case).\n\n Sverre Rabbelier (3):\n      fast-import: put option parsing code in seperate functions\n      fast-import: add option command\n      fast-import: test the new option command\n\n fast-import.c          |  137 ++++++++++++++++++++++++++++++++++++-----------\n t/t9300-fast-import.sh |   33 ++++++++++++\n 2 files changed, 138 insertions(+), 32 deletions(-)\n"},{"id":"119372","messageId":"1249189570-26576-2-git-send-email-srabbelier@gmail.com","threadId":"20342","inReplyTo":"1249189570-26576-1-git-send-email-srabbelier@gmail.com","subject":"[RFC PATCH 1/2] fast-import: put option parsing code in seperate functions","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-08-02T05:06:08Z","receivedAt":"2009-08-02T05:06:08Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Putting the options in their own functions increases readability of\nthe option parsing block and makes it easier to reuse the option\nparsing code later on.\n\nSigned-off-by: Sverre Rabbelier <srabbelier@gmail.com>\n---\n\n    I renamed import_marks to option_import_marks for consistency, since it is\n    used to deal with a certain option.\n\n fast-import.c |   98 ++++++++++++++++++++++++++++++++++++++------------------\n 1 files changed, 66 insertions(+), 32 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 7ef9865..57fff3b 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -291,6 +291,7 @@ static unsigned long branch_count;\n static unsigned long branch_load_count;\n static int failure;\n static FILE *pack_edges;\n+static unsigned int show_stats = 1;\n \n /* Memory pools */\n static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);\n@@ -2337,7 +2338,7 @@ static void parse_progress(void)\n \tskip_optional_lf();\n }\n \n-static void import_marks(const char *input_file)\n+static void option_import_marks(const char *input_file)\n {\n \tchar line[512];\n \tFILE *f = fopen(input_file, \"r\");\n@@ -2372,6 +2373,55 @@ static void import_marks(const char *input_file)\n \tfclose(f);\n }\n \n+static void option_date_format(const char *fmt) {\n+\tif (!strcmp(fmt, \"raw\"))\n+\t\twhenspec = WHENSPEC_RAW;\n+\telse if (!strcmp(fmt, \"rfc2822\"))\n+\t\twhenspec = WHENSPEC_RFC2822;\n+\telse if (!strcmp(fmt, \"now\"))\n+\t\twhenspec = WHENSPEC_NOW;\n+\telse\n+\t\tdie(\"unknown --date-format argument %s\", fmt);\n+}\n+\n+static void option_max_pack_size(const char *packsize) {\n+\tmax_packsize = strtoumax(packsize, NULL, 0) * 1024 * 1024;\n+}\n+\n+static void option_depth(const char *depth) {\n+\tmax_depth = strtoul(depth, NULL, 0);\n+\tif (max_depth > MAX_DEPTH)\n+\t\tdie(\"--depth cannot exceed %u\", MAX_DEPTH);\n+}\n+\n+static void option_active_branches(const char *branches) {\n+\tmax_active_branches = strtoul(branches, NULL, 0);\n+}\n+\n+static void option_export_marks(const char *marks) {\n+\tmark_file = marks;\n+}\n+\n+static void option_export_pack_edges(const char *edges) {\n+\tif (pack_edges)\n+\t\tfclose(pack_edges);\n+\tpack_edges = fopen(edges, \"a\");\n+\tif (!pack_edges)\n+\t\tdie_errno(\"Cannot open '%s'\", edges);\n+}\n+\n+static void option_force() {\n+\tforce_update = 1;\n+}\n+\n+static void option_quiet() {\n+\tshow_stats = 0;\n+}\n+\n+static void option_stats() {\n+\tshow_stats = 1;\n+}\n+\n static int git_pack_config(const char *k, const char *v, void *cb)\n {\n \tif (!strcmp(k, \"pack.depth\")) {\n@@ -2398,7 +2448,7 @@ static const char fast_import_usage[] =\n \n int main(int argc, const char **argv)\n {\n-\tunsigned int i, show_stats = 1;\n+\tunsigned int i;\n \n \tgit_extract_argv0_path(argv[0]);\n \n@@ -2419,42 +2469,26 @@ int main(int argc, const char **argv)\n \n \t\tif (*a != '-' || !strcmp(a, \"--\"))\n \t\t\tbreak;\n-\t\telse if (!prefixcmp(a, \"--date-format=\")) {\n-\t\t\tconst char *fmt = a + 14;\n-\t\t\tif (!strcmp(fmt, \"raw\"))\n-\t\t\t\twhenspec = WHENSPEC_RAW;\n-\t\t\telse if (!strcmp(fmt, \"rfc2822\"))\n-\t\t\t\twhenspec = WHENSPEC_RFC2822;\n-\t\t\telse if (!strcmp(fmt, \"now\"))\n-\t\t\t\twhenspec = WHENSPEC_NOW;\n-\t\t\telse\n-\t\t\t\tdie(\"unknown --date-format argument %s\", fmt);\n-\t\t}\n+\t\telse if (!prefixcmp(a, \"--date-format=\"))\n+\t\t\toption_date_format(a + 14);\n \t\telse if (!prefixcmp(a, \"--max-pack-size=\"))\n-\t\t\tmax_packsize = strtoumax(a + 16, NULL, 0) * 1024 * 1024;\n-\t\telse if (!prefixcmp(a, \"--depth=\")) {\n-\t\t\tmax_depth = strtoul(a + 8, NULL, 0);\n-\t\t\tif (max_depth > MAX_DEPTH)\n-\t\t\t\tdie(\"--depth cannot exceed %u\", MAX_DEPTH);\n-\t\t}\n+\t\t\toption_max_pack_size(a + 16);\n+\t\telse if (!prefixcmp(a, \"--depth=\"))\n+\t\t\toption_depth(a + 8);\n \t\telse if (!prefixcmp(a, \"--active-branches=\"))\n-\t\t\tmax_active_branches = strtoul(a + 18, NULL, 0);\n+\t\t\toption_active_branches(a + 18);\n \t\telse if (!prefixcmp(a, \"--import-marks=\"))\n-\t\t\timport_marks(a + 15);\n+\t\t\toption_import_marks(a + 15);\n \t\telse if (!prefixcmp(a, \"--export-marks=\"))\n-\t\t\tmark_file = a + 15;\n-\t\telse if (!prefixcmp(a, \"--export-pack-edges=\")) {\n-\t\t\tif (pack_edges)\n-\t\t\t\tfclose(pack_edges);\n-\t\t\tpack_edges = fopen(a + 20, \"a\");\n-\t\t\tif (!pack_edges)\n-\t\t\t\tdie_errno(\"Cannot open '%s'\", a + 20);\n-\t\t} else if (!strcmp(a, \"--force\"))\n-\t\t\tforce_update = 1;\n+\t\t\toption_export_marks(a + 15);\n+\t\telse if (!prefixcmp(a, \"--export-pack-edges=\"))\n+\t\t\toption_export_pack_edges(a + 20);\n+\t\telse if (!strcmp(a, \"--force\"))\n+\t\t\toption_force();\n \t\telse if (!strcmp(a, \"--quiet\"))\n-\t\t\tshow_stats = 0;\n+\t\t\toption_quiet();\n \t\telse if (!strcmp(a, \"--stats\"))\n-\t\t\tshow_stats = 1;\n+\t\t\toption_stats();\n \t\telse\n \t\t\tdie(\"unknown option %s\", a);\n \t}\n-- \n1.6.3.GIT\n"},{"id":"119373","messageId":"1249189570-26576-3-git-send-email-srabbelier@gmail.com","threadId":"20342","inReplyTo":"1249189570-26576-2-git-send-email-srabbelier@gmail.com","subject":"[RFC PATCH 2/2] fast-import: add option command","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-08-02T05:06:09Z","receivedAt":"2009-08-02T05:06:09Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"This allows the frontend to specify any of the supported options as\nlong as no non-option command has been given. This way the\nuser does not have to include any frontend-specific options, but\ninstead she can rely on the frontend to tell fast-import what it\nneeds.\n\nSigned-off-by: Sverre Rabbelier <srabbelier@gmail.com>\n---\n\n    This addds an extra prefixcmp for each command, but only for the\n    first command, and any 'option' commands. I felt that was better\n    than to add seen_non_option_command=1 to each other command.\n\n fast-import.c |   39 +++++++++++++++++++++++++++++++++++++++\n 1 files changed, 39 insertions(+), 0 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 57fff3b..2007ed8 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -348,6 +348,7 @@ static struct recent_command *rc_free;\n static unsigned int cmd_save = 100;\n static uintmax_t next_mark;\n static struct strbuf new_data = STRBUF_INIT;\n+static int seen_non_option_command;\n \n static void write_branch_report(FILE *rpt, struct branch *b)\n {\n@@ -1663,6 +1664,10 @@ static int read_next_command(void)\n \t\t\tif (stdin_eof)\n \t\t\t\treturn EOF;\n \n+\t\t\tif (!seen_non_option_command\n+\t\t\t\t&& prefixcmp(command_buf.buf, \"option \"))\n+\t\t\t\tseen_non_option_command = 1;\n+\n \t\t\trc = rc_free;\n \t\t\tif (rc)\n \t\t\t\trc_free = rc->next;\n@@ -2422,6 +2427,38 @@ static void option_stats() {\n \tshow_stats = 1;\n }\n \n+static void parse_option(void)\n+{\n+    char* option = command_buf.buf + 7;\n+\n+\tif (seen_non_option_command)\n+\t\tdie(\"Got option command '%s' after non-option command\", option);\n+\n+    if (!prefixcmp(option, \"date-format\")) {\n+\t\toption_date_format(option + 12);\n+    } else if (!prefixcmp(option, \"max-pack-size\")) {\n+\t\toption_max_pack_size(option + 14);\n+    } else if (!prefixcmp(option, \"depth\")) {\n+\t\toption_depth(option + 6);\n+    } else if (!prefixcmp(option, \"active-branches\")) {\n+\t\toption_active_branches(option + 16);\n+    } else if (!prefixcmp(option, \"import-marks\")) {\n+\t\toption_import_marks(option + 13);\n+    } else if (!prefixcmp(option, \"export-marks\")) {\n+\t\toption_export_marks(option + 13);\n+    } else if (!prefixcmp(option, \"export-pack-edges\")) {\n+\t\toption_export_pack_edges(option + 18);\n+    } else if (!prefixcmp(option, \"force\")) {\n+\t\toption_force();\n+    } else if (!prefixcmp(option, \"quiet\")) {\n+\t\toption_quiet();\n+    } else if (!prefixcmp(option, \"stats\")) {\n+\t\toption_stats();\n+    } else {\n+\t\tdie(\"Unsupported option: %s\", option);\n+    }\n+}\n+\n static int git_pack_config(const char *k, const char *v, void *cb)\n {\n \tif (!strcmp(k, \"pack.depth\")) {\n@@ -2516,6 +2553,8 @@ int main(int argc, const char **argv)\n \t\t\tparse_checkpoint();\n \t\telse if (!prefixcmp(command_buf.buf, \"progress \"))\n \t\t\tparse_progress();\n+\t\telse if (!prefixcmp(command_buf.buf, \"option \"))\n+\t\t\tparse_option();\n \t\telse\n \t\t\tdie(\"Unsupported command: %s\", command_buf.buf);\n \t}\n-- \n1.6.3.GIT\n"},{"id":"119374","messageId":"1249189570-26576-4-git-send-email-srabbelier@gmail.com","threadId":"20342","inReplyTo":"1249189570-26576-3-git-send-email-srabbelier@gmail.com","subject":"[RFC PATCH 3/3] fast-import: test the new option command","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-08-02T05:06:10Z","receivedAt":"2009-08-02T05:06:10Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Test the new 'option' command to fast-import to make sure that they\nindeed affect the behavior in the same way as the commandline\noptions.\n\nSigned-off-by: Sverre Rabbelier <srabbelier@gmail.com>\n---\n\n    Since the option code is now very similar, I feel confident that\n    it works after testing two random [0] options.\n\n    [0] where with random I mean 'easy to test'\n\n t/t9300-fast-import.sh |   33 +++++++++++++++++++++++++++++++++\n 1 files changed, 33 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh\nindex 821be7c..a5afe9a 100755\n--- a/t/t9300-fast-import.sh\n+++ b/t/t9300-fast-import.sh\n@@ -1088,4 +1088,37 @@ INPUT_END\n test_expect_success 'P: fail on blob mark in gitlink' '\n     test_must_fail git fast-import <input'\n \n+###\n+### series Q (options)\n+###\n+\n+cat >input << EOF\n+option quiet\n+blob\n+data 3\n+hi\n+\n+EOF\n+\n+touch empty\n+\n+test_expect_success 'Q: quiet option results in no stats being output' '\n+    cat input | git fast-import 2> output &&\n+    test_cmp empty output\n+'\n+\n+cat >input << EOF\n+option export-marks git.marks\n+blob\n+mark :1\n+data 3\n+hi\n+\n+EOF\n+\n+test_expect_success \\\n+    'Q: export-marks option results in a marks file being created' \\\n+    'cat input | git fast-import 2> output &&\n+    grep :1 git.marks'\n+\n test_done\n-- \n1.6.4.15.g8b2be\n"},{"id":"119377","messageId":"1249196943-13259-1-git-send-email-srabbelier@gmail.com","threadId":"20342","inReplyTo":"1249189570-26576-2-git-send-email-srabbelier@gmail.com","subject":"[RFC PATCH v1a 1/3] fast-import: put option parsing code in seperate functions","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-08-02T07:09:03Z","receivedAt":"2009-08-02T07:09:03Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Putting the options in their own functions increases readability of\nthe option parsing block and makes it easier to reuse the option\nparsing code later on.\n\nSigned-off-by: Sverre Rabbelier <srabbelier@gmail.com>\n---\n\n    Good thing nobody saw my patch yet, it has a bug already.\n    It used to be ok to assign the contents of *a to the marks_file\n    since *a came from argv, which does not change. However, since\n    the function is being factored out for future use where we cannot\n    be sure about the validity of the argument after we return, it\n    should be copied. All other options convert the argument into\n    a safe value type (integer, etc).\n\n fast-import.c |  100 ++++++++++++++++++++++++++++++++++++++------------------\n 1 files changed, 68 insertions(+), 32 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 7ef9865..f624f08 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -291,6 +291,7 @@ static unsigned long branch_count;\n static unsigned long branch_load_count;\n static int failure;\n static FILE *pack_edges;\n+static unsigned int show_stats = 1;\n \n /* Memory pools */\n static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);\n@@ -2337,7 +2338,7 @@ static void parse_progress(void)\n \tskip_optional_lf();\n }\n \n-static void import_marks(const char *input_file)\n+static void option_import_marks(const char *input_file)\n {\n \tchar line[512];\n \tFILE *f = fopen(input_file, \"r\");\n@@ -2372,6 +2373,57 @@ static void import_marks(const char *input_file)\n \tfclose(f);\n }\n \n+static void option_date_format(const char *fmt) {\n+\tif (!strcmp(fmt, \"raw\"))\n+\t\twhenspec = WHENSPEC_RAW;\n+\telse if (!strcmp(fmt, \"rfc2822\"))\n+\t\twhenspec = WHENSPEC_RFC2822;\n+\telse if (!strcmp(fmt, \"now\"))\n+\t\twhenspec = WHENSPEC_NOW;\n+\telse\n+\t\tdie(\"unknown --date-format argument %s\", fmt);\n+}\n+\n+static void option_max_pack_size(const char *packsize) {\n+\tmax_packsize = strtoumax(packsize, NULL, 0) * 1024 * 1024;\n+}\n+\n+static void option_depth(const char *depth) {\n+\tmax_depth = strtoul(depth, NULL, 0);\n+\tif (max_depth > MAX_DEPTH)\n+\t\tdie(\"--depth cannot exceed %u\", MAX_DEPTH);\n+}\n+\n+static void option_active_branches(const char *branches) {\n+\tmax_active_branches = strtoul(branches, NULL, 0);\n+}\n+\n+static void option_export_marks(const char *marks) {\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tstrbuf_addstr(&buf, marks);\n+\tmark_file = strbuf_detach(&buf, NULL);\n+}\n+\n+static void option_export_pack_edges(const char *edges) {\n+\tif (pack_edges)\n+\t\tfclose(pack_edges);\n+\tpack_edges = fopen(edges, \"a\");\n+\tif (!pack_edges)\n+\t\tdie_errno(\"Cannot open '%s'\", edges);\n+}\n+\n+static void option_force() {\n+\tforce_update = 1;\n+}\n+\n+static void option_quiet() {\n+\tshow_stats = 0;\n+}\n+\n+static void option_stats() {\n+\tshow_stats = 1;\n+}\n+\n static int git_pack_config(const char *k, const char *v, void *cb)\n {\n \tif (!strcmp(k, \"pack.depth\")) {\n@@ -2398,7 +2450,7 @@ static const char fast_import_usage[] =\n \n int main(int argc, const char **argv)\n {\n-\tunsigned int i, show_stats = 1;\n+\tunsigned int i;\n \n \tgit_extract_argv0_path(argv[0]);\n \n@@ -2419,42 +2471,26 @@ int main(int argc, const char **argv)\n \n \t\tif (*a != '-' || !strcmp(a, \"--\"))\n \t\t\tbreak;\n-\t\telse if (!prefixcmp(a, \"--date-format=\")) {\n-\t\t\tconst char *fmt = a + 14;\n-\t\t\tif (!strcmp(fmt, \"raw\"))\n-\t\t\t\twhenspec = WHENSPEC_RAW;\n-\t\t\telse if (!strcmp(fmt, \"rfc2822\"))\n-\t\t\t\twhenspec = WHENSPEC_RFC2822;\n-\t\t\telse if (!strcmp(fmt, \"now\"))\n-\t\t\t\twhenspec = WHENSPEC_NOW;\n-\t\t\telse\n-\t\t\t\tdie(\"unknown --date-format argument %s\", fmt);\n-\t\t}\n+\t\telse if (!prefixcmp(a, \"--date-format=\"))\n+\t\t\toption_date_format(a + 14);\n \t\telse if (!prefixcmp(a, \"--max-pack-size=\"))\n-\t\t\tmax_packsize = strtoumax(a + 16, NULL, 0) * 1024 * 1024;\n-\t\telse if (!prefixcmp(a, \"--depth=\")) {\n-\t\t\tmax_depth = strtoul(a + 8, NULL, 0);\n-\t\t\tif (max_depth > MAX_DEPTH)\n-\t\t\t\tdie(\"--depth cannot exceed %u\", MAX_DEPTH);\n-\t\t}\n+\t\t\toption_max_pack_size(a + 16);\n+\t\telse if (!prefixcmp(a, \"--depth=\"))\n+\t\t\toption_depth(a + 8);\n \t\telse if (!prefixcmp(a, \"--active-branches=\"))\n-\t\t\tmax_active_branches = strtoul(a + 18, NULL, 0);\n+\t\t\toption_active_branches(a + 18);\n \t\telse if (!prefixcmp(a, \"--import-marks=\"))\n-\t\t\timport_marks(a + 15);\n+\t\t\toption_import_marks(a + 15);\n \t\telse if (!prefixcmp(a, \"--export-marks=\"))\n-\t\t\tmark_file = a + 15;\n-\t\telse if (!prefixcmp(a, \"--export-pack-edges=\")) {\n-\t\t\tif (pack_edges)\n-\t\t\t\tfclose(pack_edges);\n-\t\t\tpack_edges = fopen(a + 20, \"a\");\n-\t\t\tif (!pack_edges)\n-\t\t\t\tdie_errno(\"Cannot open '%s'\", a + 20);\n-\t\t} else if (!strcmp(a, \"--force\"))\n-\t\t\tforce_update = 1;\n+\t\t\toption_export_marks(a + 15);\n+\t\telse if (!prefixcmp(a, \"--export-pack-edges=\"))\n+\t\t\toption_export_pack_edges(a + 20);\n+\t\telse if (!strcmp(a, \"--force\"))\n+\t\t\toption_force();\n \t\telse if (!strcmp(a, \"--quiet\"))\n-\t\t\tshow_stats = 0;\n+\t\t\toption_quiet();\n \t\telse if (!strcmp(a, \"--stats\"))\n-\t\t\tshow_stats = 1;\n+\t\t\toption_stats();\n \t\telse\n \t\t\tdie(\"unknown option %s\", a);\n \t}\n-- \n1.6.4.16.g72c66.dirty\n"},{"id":"119388","messageId":"20090803001522.GE1033@spearce.org","threadId":"20342","inReplyTo":"1249189570-26576-1-git-send-email-srabbelier@gmail.com","subject":"Re: [RFC PATCH 0/3] fast-import: add option command","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-08-03T00:15:22Z","receivedAt":"2009-08-03T00:15:22Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Sverre Rabbelier <srabbelier@gmail.com> wrote:\n>     This allows the frontend to specify any of the supported options as\n>     long as no non-option command has been given. This way the\n>     user does not have to include any frontend-specific options, but\n>     instead she can rely on the frontend to tell fast-import what it\n>     needs.\n...\n>  fast-import.c          |  137 ++++++++++++++++++++++++++++++++++++-----------\n>  t/t9300-fast-import.sh |   33 ++++++++++++\n>  2 files changed, 138 insertions(+), 32 deletions(-)\n\nSome comments:\n\nSince you are changing the language format, please also update the\ndocumentation of the language.\n\nIt might be cleaner to say \"option foo=value\\n\" because then the\nif block to parse the command line and the if block to parse the\ninput stream are the same.  When parsing argv just skip the \"--\"\nand pass the rest of the argv value into the function, when parsing\nthe stream, just skip the \"option \" and pass the rest of the line\ninto the function.\n\nThis has come up before on the list.  We had somewhat decided against\nsetting options in the stream header.  The only option class that\nreally impacts the data itself is the date format, all others\nare about local file paths or how noisy the command should be.\nThus we decided that the frontend should invoke `git fast-import`\nitself if it cared about these options, and that's what any typical\nfrontend does.\n\n-- \nShawn.\n"},{"id":"119391","messageId":"fabb9a1e0908022131m454aee84laa5d276bba8b10e1@mail.gmail.com","threadId":"20342","inReplyTo":"20090803001522.GE1033@spearce.org","subject":"Re: [RFC PATCH 0/3] fast-import: add option command","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-08-03T04:31:54Z","receivedAt":"2009-08-03T04:31:54Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Sun, Aug 2, 2009 at 17:15, Shawn O. Pearce<spearce@spearce.org> wrote:>\n> Since you are changing the language format, please also update the\n> documentation of the language.\n\nOf course, but I wanted to know whether the change'd be accepted first :).\n\n> It might be cleaner to say \"option foo=value\\n\" because then the\n> if block to parse the command line and the if block to parse the\n> input stream are the same.  When parsing argv just skip the \"--\"\n> and pass the rest of the argv value into the function, when parsing\n> the stream, just skip the \"option \" and pass the rest of the line\n> into the function.\n\nsounds like a good idea, will do.\n\n> This has come up before on the list.  We had somewhat decided against\n> setting options in the stream header.  The only option class that\n> really impacts the data itself is the date format, all others\n> are about local file paths or how noisy the command should be.\n> Thus we decided that the frontend should invoke `git fast-import`\n> itself if it cared about these options, and that's what any typical\n> frontend does.\n\nHmmm, yes, I guess that's possible, but that would require the\nfrontend to shell out, whereas the option-based approach is easier to\nthe user without requiring the frontend to know how to invoke git. And\nwhile the only option that impacts the data format is the date format,\nthe import and export marks are very relevant when the frontend wants\nto do post-processing of the exported repository. I guess the question\nis, do we want to require frontends to create a wrapper around\n'frontend | git fast-import --all-my=options', or is just \"fronted |\ngit fast-import\" desirable enough that we want to allow this?\n\n-- \nCheers,\n\nSverre Rabbelier\n"}]}