{"thread":{"id":"14641","subject":"[PATCH 7/9] builtin-checkout-index.c: use parse_options()","startedAt":"2008-07-23T21:42:03Z","lastAt":"2008-07-28T12:10:22Z","messageCount":31,"participants":["Michele Ballabio","Johannes Schindelin","Olivier Marin","Sverre Rabbelier","René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"84612","messageId":"1216849332-26813-1-git-send-email-barra_cuda@katamail.com","threadId":"14641","inReplyTo":null,"subject":"[PATCH 0/9] Extend use of parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-23T21:42:03Z","receivedAt":"2008-07-23T21:42:03Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"These patches spread the use of parse_options() to some more commands.\nI tried to come up with a short description for every option, but\nI'm not sure I fully succeeded. In particular, the option \"sparse\"\nin builtin-rev-list.c has no description.\n\nMichele Ballabio (9):\n  builtin-verify-tag.c: use parse_options()\n  builtin-write-tree.c: use parse_options()\n  builtin-prune-packed.c: use parse_options()\n  builtin-ls-tree.c: use parse_options()\n  builtin-rev-list.c: use parse_options()\n  builtin-init-db.c: use parse_options()\n  builtin-checkout-index.c: use parse_options()\n  builtin-fetch-pack.c: use parse_options()\n  builtin-mailinfo.c: use parse_options()\n\n builtin-checkout-index.c |  146 +++++++++++++++++++++++++---------------------\n builtin-fetch-pack.c     |  144 ++++++++++++++++++++++++++++-----------------\n builtin-init-db.c        |   56 +++++++++++-------\n builtin-ls-tree.c        |   92 +++++++++++------------------\n builtin-mailinfo.c       |   39 +++++++------\n builtin-prune-packed.c   |   38 ++++++------\n builtin-rev-list.c       |  132 ++++++++++++++++++++---------------------\n builtin-verify-tag.c     |   25 +++++---\n builtin-write-tree.c     |   31 +++++-----\n 9 files changed, 376 insertions(+), 327 deletions(-)\n"},{"id":"84611","messageId":"1216849332-26813-2-git-send-email-barra_cuda@katamail.com","threadId":"14641","inReplyTo":"1216849332-26813-1-git-send-email-barra_cuda@katamail.com","subject":"[PATCH 1/9] builtin-verify-tag.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-23T21:42:04Z","receivedAt":"2008-07-23T21:42:04Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\n builtin-verify-tag.c |   25 +++++++++++++++----------\n 1 files changed, 15 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin-verify-tag.c b/builtin-verify-tag.c\nindex 7d837f0..590038b 100644\n--- a/builtin-verify-tag.c\n+++ b/builtin-verify-tag.c\n@@ -9,10 +9,13 @@\n #include \"builtin.h\"\n #include \"tag.h\"\n #include \"run-command.h\"\n+#include \"parse-options.h\"\n #include <signal.h>\n \n-static const char builtin_verify_tag_usage[] =\n-\t\t\"git verify-tag [-v|--verbose] <tag>...\";\n+static const char * const builtin_verify_tag_usage[] = {\n+\t\"git verify-tag [-v|--verbose] <tag>...\",\n+\tNULL\n+};\n \n #define PGP_SIGNATURE \"-----BEGIN PGP SIGNATURE-----\"\n \n@@ -88,23 +91,25 @@ static int verify_tag(const char *name, int verbose)\n \n int cmd_verify_tag(int argc, const char **argv, const char *prefix)\n {\n-\tint i = 1, verbose = 0, had_error = 0;\n+\tint verbose = 0, had_error = 0;\n \n \tgit_config(git_default_config, NULL);\n \n+\tconst struct option options[] = {\n+\t\tOPT__VERBOSE(&verbose),\n+\t\tOPT_END()\n+\t};\n+\n \tif (argc == 1)\n-\t\tusage(builtin_verify_tag_usage);\n+\t\tusage_with_options(builtin_verify_tag_usage, options);\n \n-\tif (!strcmp(argv[i], \"-v\") || !strcmp(argv[i], \"--verbose\")) {\n-\t\tverbose = 1;\n-\t\ti++;\n-\t}\n+\targc = parse_options(argc, argv, options, builtin_verify_tag_usage, 0);\n \n \t/* sometimes the program was terminated because this signal\n \t * was received in the process of writing the gpg input: */\n \tsignal(SIGPIPE, SIG_IGN);\n-\twhile (i < argc)\n-\t\tif (verify_tag(argv[i++], verbose))\n+\twhile (argc-- > 0)\n+\t\tif (verify_tag(*argv++, verbose))\n \t\t\thad_error = 1;\n \treturn had_error;\n }\n-- \n1.5.6.3\n"},{"id":"84613","messageId":"1216849332-26813-3-git-send-email-barra_cuda@katamail.com","threadId":"14641","inReplyTo":"1216849332-26813-1-git-send-email-barra_cuda@katamail.com","subject":"[PATCH 2/9] builtin-write-tree.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-23T21:42:05Z","receivedAt":"2008-07-23T21:42:05Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\n builtin-write-tree.c |   31 +++++++++++++++++--------------\n 1 files changed, 17 insertions(+), 14 deletions(-)\n\ndiff --git a/builtin-write-tree.c b/builtin-write-tree.c\nindex 52a3c01..25f3d8a 100644\n--- a/builtin-write-tree.c\n+++ b/builtin-write-tree.c\n@@ -7,9 +7,12 @@\n #include \"cache.h\"\n #include \"tree.h\"\n #include \"cache-tree.h\"\n+#include \"parse-options.h\"\n \n-static const char write_tree_usage[] =\n-\"git write-tree [--missing-ok] [--prefix=<prefix>/]\";\n+static const char * const write_tree_usage[] = {\n+\t\"git write-tree [--missing-ok] [--prefix=<directory>/]\",\n+\tNULL\n+};\n \n int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)\n {\n@@ -19,19 +22,19 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)\n \tconst char *me = \"git-write-tree\";\n \n \tgit_config(git_default_config, NULL);\n-\twhile (1 < argc) {\n-\t\tconst char *arg = argv[1];\n-\t\tif (!strcmp(arg, \"--missing-ok\"))\n-\t\t\tmissing_ok = 1;\n-\t\telse if (!prefixcmp(arg, \"--prefix=\"))\n-\t\t\tprefix = arg + 9;\n-\t\telse\n-\t\t\tusage(write_tree_usage);\n-\t\targc--; argv++;\n-\t}\n \n-\tif (argc > 2)\n-\t\tdie(\"too many options\");\n+\tconst struct option options[] = {\n+\t\tOPT_BOOLEAN(0, \"missing-ok\", &missing_ok,\n+\t\t\t    \"disable existence check\"),\n+\t\tOPT_STRING(0, \"prefix\", &prefix, \"directory\",\n+\t\t\t   \"write a tree object for <directory>\"),\n+\t\tOPT_END()\n+\t};\n+\n+\targc = parse_options(argc, argv, options, write_tree_usage, 0);\n+\n+\tif (argc > 0)\n+\t\tusage_with_options(write_tree_usage, options);\n \n \tret = write_cache_as_tree(sha1, missing_ok, prefix);\n \tswitch (ret) {\n-- \n1.5.6.3\n"},{"id":"84617","messageId":"1216849332-26813-4-git-send-email-barra_cuda@katamail.com","threadId":"14641","inReplyTo":"1216849332-26813-1-git-send-email-barra_cuda@katamail.com","subject":"[PATCH 3/9] builtin-prune-packed.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-23T21:42:06Z","receivedAt":"2008-07-23T21:42:06Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\n builtin-prune-packed.c |   38 ++++++++++++++++++--------------------\n 1 files changed, 18 insertions(+), 20 deletions(-)\n\ndiff --git a/builtin-prune-packed.c b/builtin-prune-packed.c\nindex 10cb8df..5866871 100644\n--- a/builtin-prune-packed.c\n+++ b/builtin-prune-packed.c\n@@ -1,12 +1,15 @@\n #include \"builtin.h\"\n #include \"cache.h\"\n #include \"progress.h\"\n+#include \"parse-options.h\"\n \n-static const char prune_packed_usage[] =\n-\"git prune-packed [-n] [-q]\";\n+static const char * const prune_packed_usage[] = {\n+\t\"git prune-packed [-n] [-q]\",\n+\tNULL\n+};\n \n #define DRY_RUN 01\n-#define VERBOSE 02\n+#define QUIET 02\n \n static struct progress *progress;\n \n@@ -43,7 +46,7 @@ void prune_packed_objects(int opts)\n \tconst char *dir = get_object_directory();\n \tint len = strlen(dir);\n \n-\tif (opts == VERBOSE)\n+\tif (!opts)\n \t\tprogress = start_progress_delay(\"Removing duplicate objects\",\n \t\t\t256, 95, 2);\n \n@@ -67,24 +70,19 @@ void prune_packed_objects(int opts)\n \n int cmd_prune_packed(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n-\tint opts = VERBOSE;\n+\tint opts = 0;\n \n-\tfor (i = 1; i < argc; i++) {\n-\t\tconst char *arg = argv[i];\n+\tconst struct option options[] = {\n+\t\tOPT_BIT('n', \"dry-run\", &opts, \"dry run\", DRY_RUN),\n+\t\tOPT_BIT('q', \"quiet\", &opts, \"be quiet\", QUIET),\n+\t\tOPT_END()\n+\t};\n+\n+\targc = parse_options(argc, argv, options, prune_packed_usage, 0);\n+\n+\tif (argc > 0)\n+\t\tusage_with_options(prune_packed_usage, options);\n \n-\t\tif (*arg == '-') {\n-\t\t\tif (!strcmp(arg, \"-n\"))\n-\t\t\t\topts |= DRY_RUN;\n-\t\t\telse if (!strcmp(arg, \"-q\"))\n-\t\t\t\topts &= ~VERBOSE;\n-\t\t\telse\n-\t\t\t\tusage(prune_packed_usage);\n-\t\t\tcontinue;\n-\t\t}\n-\t\t/* Handle arguments here .. */\n-\t\tusage(prune_packed_usage);\n-\t}\n \tprune_packed_objects(opts);\n \treturn 0;\n }\n-- \n1.5.6.3\n"},{"id":"84614","messageId":"1216849332-26813-5-git-send-email-barra_cuda@katamail.com","threadId":"14641","inReplyTo":"1216849332-26813-1-git-send-email-barra_cuda@katamail.com","subject":"[PATCH 4/9] builtin-ls-tree.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-23T21:42:07Z","receivedAt":"2008-07-23T21:42:07Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\n builtin-ls-tree.c |   92 +++++++++++++++++++++--------------------------------\n 1 files changed, 36 insertions(+), 56 deletions(-)\n\ndiff --git a/builtin-ls-tree.c b/builtin-ls-tree.c\nindex d25767a..a0b17aa 100644\n--- a/builtin-ls-tree.c\n+++ b/builtin-ls-tree.c\n@@ -9,6 +9,7 @@\n #include \"commit.h\"\n #include \"quote.h\"\n #include \"builtin.h\"\n+#include \"parse-options.h\"\n \n static int line_termination = '\\n';\n #define LS_RECURSIVE 1\n@@ -22,8 +23,10 @@ static const char **pathspec;\n static int chomp_prefix;\n static const char *ls_tree_prefix;\n \n-static const char ls_tree_usage[] =\n-\t\"git ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--abbrev[=<n>]] <tree-ish> [path...]\";\n+static const char * const ls_tree_usage[] = {\n+\t\"git ls-tree [options] <tree-ish> [path...]\",\n+\tNULL\n+};\n \n static int show_recursive(const char *base, int baselen, const char *pathname)\n {\n@@ -122,70 +125,47 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)\n \tunsigned char sha1[20];\n \tstruct tree *tree;\n \n+\tconst struct option options[] = {\n+\t\tOPT_SET_INT('z', NULL, &line_termination,\n+\t\t\t    \"\\\\0 line termination on output\", 0),\n+\t\tOPT_BIT('r', NULL, &ls_options,\n+\t\t\t\"recurse into sub-trees\", LS_RECURSIVE),\n+\t\tOPT_BIT('d', NULL, &ls_options,\n+\t\t\t\"show only the tree, not its children\",\n+\t\t\tLS_TREE_ONLY),\n+\t\tOPT_BIT('t', NULL, &ls_options,\n+\t\t\t\"show tree entries\", LS_SHOW_TREES),\n+\t\tOPT_BIT('l', \"long\", &ls_options,\n+\t\t\t\"show object size of blob (file) entries\",\n+\t\t\tLS_SHOW_SIZE),\n+\t\tOPT_BIT(0, \"name-only\", &ls_options,\n+\t\t\t\"list only filenames\", LS_NAME_ONLY),\n+\t\tOPT_BIT(0, \"name-status\", &ls_options,\n+\t\t\t\"same as --name-only\", LS_NAME_ONLY),\n+\t\tOPT_SET_INT(0, \"full-name\", &chomp_prefix,\n+\t\t\t    \"show the full path name\", 0),\n+\t\tOPT__ABBREV(&abbrev),\n+\t\tOPT_END()\n+\t};\n+\n \tgit_config(git_default_config, NULL);\n \tls_tree_prefix = prefix;\n \tif (prefix && *prefix)\n \t\tchomp_prefix = strlen(prefix);\n-\twhile (1 < argc && argv[1][0] == '-') {\n-\t\tswitch (argv[1][1]) {\n-\t\tcase 'z':\n-\t\t\tline_termination = 0;\n-\t\t\tbreak;\n-\t\tcase 'r':\n-\t\t\tls_options |= LS_RECURSIVE;\n-\t\t\tbreak;\n-\t\tcase 'd':\n-\t\t\tls_options |= LS_TREE_ONLY;\n-\t\t\tbreak;\n-\t\tcase 't':\n-\t\t\tls_options |= LS_SHOW_TREES;\n-\t\t\tbreak;\n-\t\tcase 'l':\n-\t\t\tls_options |= LS_SHOW_SIZE;\n-\t\t\tbreak;\n-\t\tcase '-':\n-\t\t\tif (!strcmp(argv[1]+2, \"name-only\") ||\n-\t\t\t    !strcmp(argv[1]+2, \"name-status\")) {\n-\t\t\t\tls_options |= LS_NAME_ONLY;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t\tif (!strcmp(argv[1]+2, \"long\")) {\n-\t\t\t\tls_options |= LS_SHOW_SIZE;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t\tif (!strcmp(argv[1]+2, \"full-name\")) {\n-\t\t\t\tchomp_prefix = 0;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t\tif (!prefixcmp(argv[1]+2, \"abbrev=\")) {\n-\t\t\t\tabbrev = strtoul(argv[1]+9, NULL, 10);\n-\t\t\t\tif (abbrev && abbrev < MINIMUM_ABBREV)\n-\t\t\t\t\tabbrev = MINIMUM_ABBREV;\n-\t\t\t\telse if (abbrev > 40)\n-\t\t\t\t\tabbrev = 40;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t\tif (!strcmp(argv[1]+2, \"abbrev\")) {\n-\t\t\t\tabbrev = DEFAULT_ABBREV;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t\t/* otherwise fallthru */\n-\t\tdefault:\n-\t\t\tusage(ls_tree_usage);\n-\t\t}\n-\t\targc--; argv++;\n-\t}\n+\n+\targc = parse_options(argc, argv, options, ls_tree_usage, 0);\n+\n \t/* -d -r should imply -t, but -d by itself should not have to. */\n \tif ( (LS_TREE_ONLY|LS_RECURSIVE) ==\n \t    ((LS_TREE_ONLY|LS_RECURSIVE) & ls_options))\n \t\tls_options |= LS_SHOW_TREES;\n \n-\tif (argc < 2)\n-\t\tusage(ls_tree_usage);\n-\tif (get_sha1(argv[1], sha1))\n-\t\tdie(\"Not a valid object name %s\", argv[1]);\n+\tif (argc < 1)\n+\t\tusage_with_options(ls_tree_usage, options);\n+\tif (get_sha1(argv[0], sha1))\n+\t\tdie(\"Not a valid object name %s\", argv[0]);\n \n-\tpathspec = get_pathspec(prefix, argv + 2);\n+\tpathspec = get_pathspec(prefix, argv + 1);\n \ttree = parse_tree_indirect(sha1);\n \tif (!tree)\n \t\tdie(\"not a tree object\");\n-- \n1.5.6.3\n"},{"id":"84615","messageId":"1216849332-26813-6-git-send-email-barra_cuda@katamail.com","threadId":"14641","inReplyTo":"1216849332-26813-1-git-send-email-barra_cuda@katamail.com","subject":"[PATCH 5/9] builtin-rev-list.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-23T21:42:08Z","receivedAt":"2008-07-23T21:42:08Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\n builtin-rev-list.c |  132 +++++++++++++++++++++++++--------------------------\n 1 files changed, 65 insertions(+), 67 deletions(-)\n\ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex 893762c..9200b20 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -11,44 +11,16 @@\n #include \"builtin.h\"\n #include \"log-tree.h\"\n #include \"graph.h\"\n+#include \"parse-options.h\"\n \n /* bits #0-15 in revision.h */\n \n #define COUNTED\t\t(1u<<16)\n \n-static const char rev_list_usage[] =\n-\"git rev-list [OPTION] <commit-id>... [ -- paths... ]\\n\"\n-\"  limiting output:\\n\"\n-\"    --max-count=nr\\n\"\n-\"    --max-age=epoch\\n\"\n-\"    --min-age=epoch\\n\"\n-\"    --sparse\\n\"\n-\"    --no-merges\\n\"\n-\"    --remove-empty\\n\"\n-\"    --all\\n\"\n-\"    --branches\\n\"\n-\"    --tags\\n\"\n-\"    --remotes\\n\"\n-\"    --stdin\\n\"\n-\"    --quiet\\n\"\n-\"  ordering output:\\n\"\n-\"    --topo-order\\n\"\n-\"    --date-order\\n\"\n-\"    --reverse\\n\"\n-\"  formatting output:\\n\"\n-\"    --parents\\n\"\n-\"    --children\\n\"\n-\"    --objects | --objects-edge\\n\"\n-\"    --unpacked\\n\"\n-\"    --header | --pretty\\n\"\n-\"    --abbrev=nr | --no-abbrev\\n\"\n-\"    --abbrev-commit\\n\"\n-\"    --left-right\\n\"\n-\"  special purpose:\\n\"\n-\"    --bisect\\n\"\n-\"    --bisect-vars\\n\"\n-\"    --bisect-all\"\n-;\n+static const char * const rev_list_usage[] = {\n+\t\"git rev-list [OPTION] <commit-id>... [ -- paths... ]\",\n+\tNULL\n+};\n \n static struct rev_info revs;\n \n@@ -575,15 +547,65 @@ static struct commit_list *find_bisection(struct commit_list *list,\n \treturn best;\n }\n \n+static int parse_header_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct rev_info *t_revs = opt->value;\n+\tt_revs->verbose_header = unset ? 0 : 1;\n+\treturn 0;\n+}\n+\n int cmd_rev_list(int argc, const char **argv, const char *prefix)\n {\n \tstruct commit_list *list;\n-\tint i;\n \tint read_from_stdin = 0;\n \tint bisect_show_vars = 0;\n \tint bisect_find_all = 0;\n \tint quiet = 0;\n \n+\tconst struct option options[] = {\n+\t\tOPT_GROUP(\"limiting output:\"),\n+\t\tOPT_ARGUMENT(\"max-count=nr\", \"limit number of commits output\"),\n+\t\tOPT_ARGUMENT(\"max-age=epoch\", \"limit commits output by time\"),\n+\t\tOPT_ARGUMENT(\"min-age=epoch\", \"limit commits output by time\"),\n+\t\tOPT_ARGUMENT(\"sparse\", \"\"),\n+\t\tOPT_ARGUMENT(\"no-merges\", \"do not print merges\"),\n+\t\tOPT_ARGUMENT(\"remove-empty\", \"stop when a given path disappears from the tree\"),\n+\t\tOPT_ARGUMENT(\"all\", \"all refs\"),\n+\t\tOPT_ARGUMENT(\"branches\", \"show local branches\"),\n+\t\tOPT_ARGUMENT(\"tags\", \"show tags\"),\n+\t\tOPT_ARGUMENT(\"remotes\", \"show remote-tracking branches\"),\n+\t\tOPT_BOOLEAN(0, \"stdin\", &read_from_stdin,\n+\t\t\t    \"read commits also from command line\"),\n+\t\tOPT__QUIET(&quiet),\n+\t\tOPT_GROUP(\"ordering output:\"),\n+\t\tOPT_ARGUMENT(\"topo-order\", \"show commits in topological order\"),\n+\t\tOPT_ARGUMENT(\"date-order\", \"use date order, preserving topology\"),\n+\t\tOPT_ARGUMENT(\"reverse\", \"output commits in reverse order\"),\n+\t\tOPT_GROUP(\"formatting output:\"),\n+\t\tOPT_ARGUMENT(\"parents\", \"print the parents of the commit\"),\n+\t\tOPT_ARGUMENT(\"children\", \"print the children of the commit\"),\n+\t\tOPT_ARGUMENT(\"objects\", \"print all objects\"),\n+\t\tOPT_ARGUMENT(\"objects-edge\", \"similar to --objects, used by git-pack-objects\"),\n+\t\tOPT_ARGUMENT(\"unpacked\", \"print objects not in packs\"),\n+\t\t{ OPTION_CALLBACK, 0, \"header\", &revs, NULL,\n+\t\t  \"use raw-format\", PARSE_OPT_NOARG, parse_header_cb, 0 },\n+\t\tOPT_ARGUMENT(\"pretty\", \"print contents in a given format\"),\n+\t\tOPT_BOOLEAN(0, \"timestamp\", &show_timestamp,\n+\t\t\t    \"print the raw commit timestamp\"),\n+\t\tOPT_ARGUMENT(\"abbrev-commit\", \"show short sha1\"),\n+\t\tOPT_ARGUMENT(\"abbrev=nr\", \"number of digits used for short sha1\"),\n+\t\tOPT_ARGUMENT(\"no-abbrev\", \"do not use short sha1\"),\n+\t\tOPT_ARGUMENT(\"left-right\", \"mark side of symmetric diff\"),\n+\t\tOPT_ARGUMENT(\"graph\", \"show an ASCII graph\"),\n+\t\tOPT_GROUP(\"special purpose:\"),\n+\t\tOPT_BOOLEAN(0, \"bisect\", &bisect_list, \"useful for binary searches\"),\n+\t\tOPT_BOOLEAN(0, \"bisect-all\", &bisect_find_all,\n+\t\t\t    \"order commits by their distance from given commits\"),\n+\t\tOPT_BOOLEAN(0, \"bisect-vars\", &bisect_show_vars,\n+\t\t\t    \"like --bisect, but ready to be eval'ed\"),\n+\t\tOPT_END()\n+\t};\n+\n \tgit_config(git_default_config, NULL);\n \tinit_revisions(&revs, prefix);\n \trevs.abbrev = 0;\n@@ -591,40 +613,16 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \targc = setup_revisions(argc, argv, &revs, NULL);\n \n \tquiet = DIFF_OPT_TST(&revs.diffopt, QUIET);\n-\tfor (i = 1 ; i < argc; i++) {\n-\t\tconst char *arg = argv[i];\n+\targc = parse_options(argc, argv, options, rev_list_usage, 0);\n \n-\t\tif (!strcmp(arg, \"--header\")) {\n-\t\t\trevs.verbose_header = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--timestamp\")) {\n-\t\t\tshow_timestamp = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--bisect\")) {\n-\t\t\tbisect_list = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--bisect-all\")) {\n-\t\t\tbisect_list = 1;\n-\t\t\tbisect_find_all = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--bisect-vars\")) {\n-\t\t\tbisect_list = 1;\n-\t\t\tbisect_show_vars = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--stdin\")) {\n-\t\t\tif (read_from_stdin++)\n-\t\t\t\tdie(\"--stdin given twice?\");\n-\t\t\tread_revisions_from_stdin(&revs);\n-\t\t\tcontinue;\n-\t\t}\n-\t\tusage(rev_list_usage);\n+\tif (argc > 0)\n+\t\tusage_with_options(rev_list_usage, options);\n+\n+\tif (bisect_find_all || bisect_show_vars)\n+\t\tbisect_list = 1;\n+\tif (read_from_stdin)\n+\t\tread_revisions_from_stdin(&revs);\n \n-\t}\n \tif (revs.commit_format != CMIT_FMT_UNSPECIFIED) {\n \t\t/* The command line has a --pretty  */\n \t\thdr_termination = '\\n';\n@@ -643,7 +641,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \t     (!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&\n \t      !revs.pending.nr)) ||\n \t    revs.diff)\n-\t\tusage(rev_list_usage);\n+\t\tusage_with_options(rev_list_usage, options);\n \n \tsave_commit_buffer = revs.verbose_header || revs.grep_filter;\n \tif (bisect_list)\n-- \n1.5.6.3\n"},{"id":"84608","messageId":"1216849332-26813-7-git-send-email-barra_cuda@katamail.com","threadId":"14641","inReplyTo":"1216849332-26813-1-git-send-email-barra_cuda@katamail.com","subject":"[PATCH 6/9] builtin-init-db.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-23T21:42:09Z","receivedAt":"2008-07-23T21:42:09Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\n builtin-init-db.c |   56 +++++++++++++++++++++++++++++++++-------------------\n 1 files changed, 35 insertions(+), 21 deletions(-)\n\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex 38b4fcb..ea1bed7 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -6,6 +6,7 @@\n #include \"cache.h\"\n #include \"builtin.h\"\n #include \"exec_cmd.h\"\n+#include \"parse-options.h\"\n \n #ifndef DEFAULT_GIT_TEMPLATE_DIR\n #define DEFAULT_GIT_TEMPLATE_DIR \"/usr/share/git-core/templates\"\n@@ -353,8 +354,17 @@ static int guess_repository_type(const char *git_dir)\n \treturn 1;\n }\n \n-static const char init_db_usage[] =\n-\"git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]]\";\n+static const char * const init_db_usage[] = {\n+\t\"git init [-q | --quiet] [--bare] [--template=<dir>] [--shared[=<type>]]\",\n+\tNULL\n+};\n+\n+static int parse_opt_shared_cb(const struct option *opt, const char *arg,\n+\t\t\t       int unset)\n+{\n+\t*(int *)(opt->value) = unset ? 0 : git_config_perm(\"arg\", arg);\n+\treturn 0;\n+}\n \n /*\n  * If you want to, you can share the DB area with any number of branches.\n@@ -367,25 +377,29 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \tconst char *git_dir;\n \tconst char *template_dir = NULL;\n \tunsigned int flags = 0;\n-\tint i;\n-\n-\tfor (i = 1; i < argc; i++, argv++) {\n-\t\tconst char *arg = argv[1];\n-\t\tif (!prefixcmp(arg, \"--template=\"))\n-\t\t\ttemplate_dir = arg+11;\n-\t\telse if (!strcmp(arg, \"--bare\")) {\n-\t\t\tstatic char git_dir[PATH_MAX+1];\n-\t\t\tis_bare_repository_cfg = 1;\n-\t\t\tsetenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir,\n-\t\t\t\t\t\tsizeof(git_dir)), 0);\n-\t\t} else if (!strcmp(arg, \"--shared\"))\n-\t\t\tshared_repository = PERM_GROUP;\n-\t\telse if (!prefixcmp(arg, \"--shared=\"))\n-\t\t\tshared_repository = git_config_perm(\"arg\", arg+9);\n-\t\telse if (!strcmp(arg, \"-q\") || !strcmp(arg, \"--quiet\"))\n-\t\t\tflags |= INIT_DB_QUIET;\n-\t\telse\n-\t\t\tusage(init_db_usage);\n+\tint bare = 0;\n+\n+\tconst struct option options[] = {\n+\t\tOPT_STRING(0, \"template\", &template_dir, \"dir\",\n+\t\t\t   \"directory from which templates will be used\"),\n+\t\tOPT_BOOLEAN(0, \"bare\", &bare, \"set up a bare repo\"),\n+\t\t{ OPTION_CALLBACK, 0, \"shared\", &shared_repository,\n+\t\t  \"type\", \"type of shared repository\",\n+\t\t  PARSE_OPT_OPTARG, parse_opt_shared_cb, PERM_GROUP },\n+\t\tOPT_BIT('q', \"quiet\", &flags, \"be quiet\", INIT_DB_QUIET),\n+\t\tOPT_END()\n+\t};\n+\n+\targc = parse_options(argc, argv, options, init_db_usage, 0);\n+\n+\tif (argc > 0)\n+\t\tusage_with_options(init_db_usage, options);\n+\n+\tif (bare) {\n+\t\tstatic char git_dir[PATH_MAX+1];\n+\t\tis_bare_repository_cfg = 1;\n+\t\tsetenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir,\n+\t\t\t\t\tsizeof(git_dir)), 0);\n \t}\n \n \t/*\n-- \n1.5.6.3\n"},{"id":"84607","messageId":"1216849332-26813-8-git-send-email-barra_cuda@katamail.com","threadId":"14641","inReplyTo":"1216849332-26813-1-git-send-email-barra_cuda@katamail.com","subject":"[PATCH 7/9] builtin-checkout-index.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-23T21:42:10Z","receivedAt":"2008-07-23T21:42:10Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\n builtin-checkout-index.c |  146 +++++++++++++++++++++++++---------------------\n 1 files changed, 79 insertions(+), 67 deletions(-)\n\ndiff --git a/builtin-checkout-index.c b/builtin-checkout-index.c\nindex 71ebabf..429c850 100644\n--- a/builtin-checkout-index.c\n+++ b/builtin-checkout-index.c\n@@ -40,6 +40,7 @@\n #include \"cache.h\"\n #include \"quote.h\"\n #include \"cache-tree.h\"\n+#include \"parse-options.h\"\n \n #define CHECKOUT_ALL 4\n static int line_termination = '\\n';\n@@ -153,18 +154,76 @@ static void checkout_all(const char *prefix, int prefix_length)\n \t\texit(128);\n }\n \n-static const char checkout_cache_usage[] =\n-\"git checkout-index [-u] [-q] [-a] [-f] [-n] [--stage=[123]|all] [--prefix=<string>] [--temp] [--] <file>...\";\n+static const char * const checkout_cache_usage[] = {\n+\t\"git checkout-index [options] [--] <file>...\",\n+\tNULL\n+};\n+\n+static int parse_state_force_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct checkout *t_state = opt->value;\n+\tt_state->force = unset ? 0 : 1;\n+\treturn 0;\n+}\n+\n+static int parse_state_quiet_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct checkout *t_state = opt->value;\n+\tt_state->quiet = unset ? 0 : 1;\n+\treturn 0;\n+}\n+\n+static int parse_state_no_create_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct checkout *t_state = opt->value;\n+\tt_state->not_new = 1;\n+\treturn 0;\n+}\n+\n+static int parse_state_index_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct checkout *t_state = opt->value;\n+\tt_state->refresh_cache = unset ? 0 : 1;\n+\treturn 0;\n+}\n \n static struct lock_file lock_file;\n \n int cmd_checkout_index(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n \tint newfd = -1;\n \tint all = 0;\n \tint read_from_stdin = 0;\n \tint prefix_length;\n+\tchar *stage = NULL;\n+\n+\tconst struct option options[] = {\n+\t\tOPT_BOOLEAN('a', \"all\", &all,\n+\t\t\t    \"checks out all files in the index\"),\n+\t\t{ OPTION_CALLBACK, 'f', \"force\", &state, NULL,\n+\t\t  \"force overwrite of existing files\",\n+\t\t  PARSE_OPT_NOARG, parse_state_force_cb, 0 },\n+\t\t{ OPTION_CALLBACK, 'q', \"quiet\", &state, NULL, \"be quiet\",\n+\t\t  PARSE_OPT_NOARG, parse_state_quiet_cb, 0 },\n+\t\t{ OPTION_CALLBACK, 'n', \"no-create\", &state, NULL,\n+\t\t  \"do not checkout new files, refresh existing ones\",\n+\t\t  PARSE_OPT_NOARG | PARSE_OPT_NONEG,\n+\t\t  parse_state_no_create_cb, 0 },\n+\t\t{ OPTION_CALLBACK, 'u', \"index\", &state, NULL,\n+\t\t  \"update stat information in the index\",\n+\t\t  PARSE_OPT_NOARG, parse_state_index_cb, 0 },\n+\t\tOPT_SET_INT('z', NULL, &line_termination,\n+\t\t\t    \"separate paths with NUL\", 0),\n+\t\tOPT_BOOLEAN(0, \"stdin\", &read_from_stdin,\n+\t\t\t    \"read paths from stdin\"),\n+\t\tOPT_BOOLEAN(0, \"temp\", &to_tempfile,\n+\t\t\t    \"write content to temporary files\"),\n+\t\tOPT_STRING(0, \"prefix\", &state.base_dir, \"string\",\n+\t\t\t   \"prepend <string> when creating files\"),\n+\t\tOPT_STRING(0, \"stage\", &stage, \"1|2|3|all\",\n+\t\t\t   \"copy out files from the named stage\"),\n+\t\tOPT_END()\n+\t};\n \n \tgit_config(git_default_config, NULL);\n \tstate.base_dir = \"\";\n@@ -174,71 +233,24 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)\n \t\tdie(\"invalid cache\");\n \t}\n \n-\tfor (i = 1; i < argc; i++) {\n-\t\tconst char *arg = argv[i];\n+\targc = parse_options(argc, argv, options, checkout_cache_usage, 0);\n \n-\t\tif (!strcmp(arg, \"--\")) {\n-\t\t\ti++;\n-\t\t\tbreak;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-a\") || !strcmp(arg, \"--all\")) {\n-\t\t\tall = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-f\") || !strcmp(arg, \"--force\")) {\n-\t\t\tstate.force = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-q\") || !strcmp(arg, \"--quiet\")) {\n-\t\t\tstate.quiet = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-n\") || !strcmp(arg, \"--no-create\")) {\n-\t\t\tstate.not_new = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-u\") || !strcmp(arg, \"--index\")) {\n-\t\t\tstate.refresh_cache = 1;\n-\t\t\tif (newfd < 0)\n-\t\t\t\tnewfd = hold_locked_index(&lock_file, 1);\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-z\")) {\n-\t\t\tline_termination = 0;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--stdin\")) {\n-\t\t\tif (i != argc - 1)\n-\t\t\t\tdie(\"--stdin must be at the end\");\n-\t\t\tread_from_stdin = 1;\n-\t\t\ti++; /* do not consider arg as a file name */\n-\t\t\tbreak;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--temp\")) {\n+\tif ((state.refresh_cache) && (newfd < 0))\n+\t\tnewfd = hold_locked_index(&lock_file, 1);\n+\tif (state.base_dir)\n+\t\tstate.base_dir_len = strlen(state.base_dir);\n+\n+\tif (stage) {\n+\t\tif (!strcmp(stage, \"all\")) {\n \t\t\tto_tempfile = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!prefixcmp(arg, \"--prefix=\")) {\n-\t\t\tstate.base_dir = arg+9;\n-\t\t\tstate.base_dir_len = strlen(state.base_dir);\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!prefixcmp(arg, \"--stage=\")) {\n-\t\t\tif (!strcmp(arg + 8, \"all\")) {\n-\t\t\t\tto_tempfile = 1;\n-\t\t\t\tcheckout_stage = CHECKOUT_ALL;\n-\t\t\t} else {\n-\t\t\t\tint ch = arg[8];\n-\t\t\t\tif ('1' <= ch && ch <= '3')\n-\t\t\t\t\tcheckout_stage = arg[8] - '0';\n-\t\t\t\telse\n-\t\t\t\t\tdie(\"stage should be between 1 and 3 or all\");\n-\t\t\t}\n-\t\t\tcontinue;\n+\t\t\tcheckout_stage = CHECKOUT_ALL;\n+\t\t} else {\n+\t\t\tint ch = stage[0];\n+\t\t\tif ('1' <= ch && ch <= '3')\n+\t\t\t\tcheckout_stage = stage[0] - '0';\n+\t\t\telse\n+\t\t\t\tdie(\"stage should be between 1 and 3 or all\");\n \t\t}\n-\t\tif (arg[0] == '-')\n-\t\t\tusage(checkout_cache_usage);\n-\t\tbreak;\n \t}\n \n \tif (state.base_dir_len || to_tempfile) {\n@@ -253,8 +265,8 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)\n \t}\n \n \t/* Check out named files first */\n-\tfor ( ; i < argc; i++) {\n-\t\tconst char *arg = argv[i];\n+\twhile (argc-- > 0) {\n+\t\tconst char *arg = *argv++;\n \t\tconst char *p;\n \n \t\tif (all)\n-- \n1.5.6.3\n"},{"id":"84610","messageId":"1216849332-26813-9-git-send-email-barra_cuda@katamail.com","threadId":"14641","inReplyTo":"1216849332-26813-1-git-send-email-barra_cuda@katamail.com","subject":"[PATCH 8/9] builtin-fetch-pack.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-23T21:42:11Z","receivedAt":"2008-07-23T21:42:11Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\n builtin-fetch-pack.c |  144 +++++++++++++++++++++++++++++++-------------------\n 1 files changed, 90 insertions(+), 54 deletions(-)\n\ndiff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c\nindex 273239a..701be41 100644\n--- a/builtin-fetch-pack.c\n+++ b/builtin-fetch-pack.c\n@@ -9,6 +9,7 @@\n #include \"fetch-pack.h\"\n #include \"remote.h\"\n #include \"run-command.h\"\n+#include \"parse-options.h\"\n \n static int transfer_unpack_limit = -1;\n static int fetch_unpack_limit = -1;\n@@ -17,8 +18,10 @@ static struct fetch_pack_args args = {\n \t/* .uploadpack = */ \"git-upload-pack\",\n };\n \n-static const char fetch_pack_usage[] =\n-\"git fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--include-tag] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]\";\n+static const char * const fetch_pack_usage[] = {\n+\t\"git fetch-pack [options] [<host>:]<directory> [<refs>...]\",\n+\tNULL\n+};\n \n #define COMPLETE\t(1U << 0)\n #define COMMON\t\t(1U << 1)\n@@ -667,6 +670,56 @@ static void fetch_pack_setup(void)\n \tdid_setup = 1;\n }\n \n+static int parse_opt_keep_pack_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct fetch_pack_args *t_args = opt->value;\n+\tt_args->lock_pack = t_args->keep_pack;\n+\tt_args->keep_pack = 1;\n+\treturn 0;\n+}\n+\n+static int parse_opt_thin_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct fetch_pack_args *t_args = opt->value;\n+\tt_args->use_thin_pack = unset ? 0 : 1;\n+\treturn 0;\n+}\n+\n+static int parse_opt_include_tag_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct fetch_pack_args *t_args = opt->value;\n+\tt_args->include_tag = unset ? 0 : 1;\n+\treturn 0;\n+}\n+\n+static int parse_opt_no_progress_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct fetch_pack_args *t_args = opt->value;\n+\tt_args->no_progress = 1;\n+\treturn 0;\n+}\n+\n+static int parse_opt_fetch_all_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct fetch_pack_args *t_args = opt->value;\n+\tt_args->fetch_all = unset ? 0 : 1;\n+\treturn 0;\n+}\n+\n+static int parse_opt_quiet_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct fetch_pack_args *t_args = opt->value;\n+\tt_args->quiet = unset ? 0 : 1;\n+\treturn 0;\n+}\n+\n+static int parse_opt_verbose_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct fetch_pack_args *t_args = opt->value;\n+\tt_args->verbose = unset ? 0 : 1;\n+\treturn 0;\n+}\n+\n int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n {\n \tint i, ret, nr_heads;\n@@ -677,60 +730,43 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n \n \tnr_heads = 0;\n \theads = NULL;\n-\tfor (i = 1; i < argc; i++) {\n-\t\tconst char *arg = argv[i];\n \n-\t\tif (*arg == '-') {\n-\t\t\tif (!prefixcmp(arg, \"--upload-pack=\")) {\n-\t\t\t\targs.uploadpack = arg + 14;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--exec=\")) {\n-\t\t\t\targs.uploadpack = arg + 7;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--quiet\", arg) || !strcmp(\"-q\", arg)) {\n-\t\t\t\targs.quiet = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--keep\", arg) || !strcmp(\"-k\", arg)) {\n-\t\t\t\targs.lock_pack = args.keep_pack;\n-\t\t\t\targs.keep_pack = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--thin\", arg)) {\n-\t\t\t\targs.use_thin_pack = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--include-tag\", arg)) {\n-\t\t\t\targs.include_tag = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--all\", arg)) {\n-\t\t\t\targs.fetch_all = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"-v\", arg)) {\n-\t\t\t\targs.verbose = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!prefixcmp(arg, \"--depth=\")) {\n-\t\t\t\targs.depth = strtol(arg + 8, NULL, 0);\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--no-progress\", arg)) {\n-\t\t\t\targs.no_progress = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tusage(fetch_pack_usage);\n-\t\t}\n-\t\tdest = (char *)arg;\n-\t\theads = (char **)(argv + i + 1);\n-\t\tnr_heads = argc - i - 1;\n-\t\tbreak;\n-\t}\n+\tconst struct option options[] = {\n+\t\t{ OPTION_CALLBACK, 0, \"all\", &args, NULL,\n+\t\t \"fetch all remote refs\", PARSE_OPT_NOARG,\n+\t\t parse_opt_fetch_all_cb },\n+\t\tOPT_STRING(0, \"upload-pack\", &args.uploadpack, \"git-upload-pack\",\n+\t\t\t   \"specify path to git-upload-pack on remote\"),\n+\t\tOPT_STRING(0, \"exec\", &args.uploadpack, \"git-upload-pack\",\n+\t\t\t   \"same as --upload-pack <git-upload-pack>.\"),\n+\t\t{ OPTION_CALLBACK, 0, \"no-progress\", &args, NULL,\n+\t\t \"do not show the progress\", PARSE_OPT_NOARG | PARSE_OPT_NONEG,\n+\t\t parse_opt_no_progress_cb },\n+\t\t{ OPTION_CALLBACK, 'q', \"quiet\", &args, NULL,\n+\t\t \"be quiet\", PARSE_OPT_NOARG, parse_opt_quiet_cb },\n+\t\t{ OPTION_CALLBACK, 'v', \"verbose\", &args, NULL,\n+\t\t \"be verbose\", PARSE_OPT_NOARG, parse_opt_verbose_cb },\n+\t\tOPT_INTEGER(0, \"depth\", &args.depth, \"fetch chains not longer than <n>\"),\n+\t\t{ OPTION_CALLBACK, 'k', \"keep\", &args, NULL,\n+\t\t \"create a single packfile of received data\",\n+\t\t PARSE_OPT_NOARG | PARSE_OPT_NONEG, parse_opt_keep_pack_cb },\n+\t\t{ OPTION_CALLBACK, 0, \"include-tag\", &args, NULL,\n+\t\t \"download annotated tags too\", PARSE_OPT_NOARG,\n+\t\t parse_opt_include_tag_cb },\n+\t\t{ OPTION_CALLBACK, 0, \"thin\", &args, NULL,\n+\t\t \"minimize number of objects to be sent\",\n+\t\t PARSE_OPT_NOARG, parse_opt_thin_cb },\n+\t\tOPT_END()\n+\t};\n+\n+\targc = parse_options(argc, argv, options, fetch_pack_usage, 0);\n+\n+\tdest = (char *)argv[0];\n+\theads = (char **)(argv + 1);\n+\tnr_heads = argc - 1;\n+\n \tif (!dest)\n-\t\tusage(fetch_pack_usage);\n+\t\tusage_with_options(fetch_pack_usage, options);\n \n \tconn = git_connect(fd, (char *)dest, args.uploadpack,\n \t\t\t   args.verbose ? CONNECT_VERBOSE : 0);\n-- \n1.5.6.3\n"},{"id":"84616","messageId":"1216849332-26813-10-git-send-email-barra_cuda@katamail.com","threadId":"14641","inReplyTo":"1216849332-26813-1-git-send-email-barra_cuda@katamail.com","subject":"[PATCH 9/9] builtin-mailinfo.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-23T21:42:12Z","receivedAt":"2008-07-23T21:42:12Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\n builtin-mailinfo.c |   39 +++++++++++++++++++++------------------\n 1 files changed, 21 insertions(+), 18 deletions(-)\n\ndiff --git a/builtin-mailinfo.c b/builtin-mailinfo.c\nindex f974b9d..f1ed269 100644\n--- a/builtin-mailinfo.c\n+++ b/builtin-mailinfo.c\n@@ -6,6 +6,7 @@\n #include \"builtin.h\"\n #include \"utf8.h\"\n #include \"strbuf.h\"\n+#include \"parse-options.h\"\n \n static FILE *cmitmsg, *patchfile, *fin, *fout;\n \n@@ -905,8 +906,10 @@ static int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,\n \treturn 0;\n }\n \n-static const char mailinfo_usage[] =\n-\t\"git mailinfo [-k] [-u | --encoding=<encoding> | -n] msg patch <mail >info\";\n+static const char * const mailinfo_usage[] = {\n+\t\"git mailinfo [-k] [-u | --encoding=<encoding> | -n] msg patch <mail >info\",\n+\tNULL\n+};\n \n int cmd_mailinfo(int argc, const char **argv, const char *prefix)\n {\n@@ -920,22 +923,22 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)\n \tdef_charset = (git_commit_encoding ? git_commit_encoding : \"utf-8\");\n \tmetainfo_charset = def_charset;\n \n-\twhile (1 < argc && argv[1][0] == '-') {\n-\t\tif (!strcmp(argv[1], \"-k\"))\n-\t\t\tkeep_subject = 1;\n-\t\telse if (!strcmp(argv[1], \"-u\"))\n-\t\t\tmetainfo_charset = def_charset;\n-\t\telse if (!strcmp(argv[1], \"-n\"))\n-\t\t\tmetainfo_charset = NULL;\n-\t\telse if (!prefixcmp(argv[1], \"--encoding=\"))\n-\t\t\tmetainfo_charset = argv[1] + 11;\n-\t\telse\n-\t\t\tusage(mailinfo_usage);\n-\t\targc--; argv++;\n-\t}\n+\tconst struct option options[] = {\n+\t\tOPT_BOOLEAN('k', NULL, &keep_subject,\n+\t\t\t    \"keep subject, don't clean it up\"),\n+\t\tOPT_SET_PTR('u', NULL, &metainfo_charset,\n+\t\t\t    \"re-code in UTF-8\", (intptr_t)def_charset),\n+\t\tOPT_SET_PTR('n', NULL, &metainfo_charset,\n+\t\t\t    \"disable re-coding\", (intptr_t)NULL),\n+\t\tOPT_STRING(0, \"encoding\", &metainfo_charset,\n+\t\t\t   \"encoding\", \"override default encoding\"),\n+\t\tOPT_END()\n+\t};\n+\n+\targc = parse_options(argc, argv, options, mailinfo_usage, 0);\n \n-\tif (argc != 3)\n-\t\tusage(mailinfo_usage);\n+\tif (argc != 2)\n+\t\tusage_with_options(mailinfo_usage, options);\n \n-\treturn !!mailinfo(stdin, stdout, keep_subject, metainfo_charset, argv[1], argv[2]);\n+\treturn !!mailinfo(stdin, stdout, keep_subject, metainfo_charset, argv[0], argv[1]);\n }\n-- \n1.5.6.3\n"},{"id":"84724","messageId":"alpine.DEB.1.00.0807241543190.8986@racer","threadId":"14641","inReplyTo":"1216849332-26813-8-git-send-email-barra_cuda@katamail.com","subject":"Re: [PATCH 7/9] builtin-checkout-index.c: use parse_options()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-24T14:44:26Z","receivedAt":"2008-07-24T14:44:26Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 23 Jul 2008, Michele Ballabio wrote:\n\n> +\t\t{ OPTION_CALLBACK, 'f', \"force\", &state, NULL,\n> +\t\t  \"force overwrite of existing files\",\n> +\t\t  PARSE_OPT_NOARG, parse_state_force_cb, 0 },\n\nI wonder if this could not be written as\n\n\t\tOPT_BOOLEAN('f', \"force\", &state.force,\n\t\t\t\"force overwrite of existing files\"),\n\nCiao,\nDscho\n"},{"id":"84733","messageId":"4888AAB2.5050007@free.fr","threadId":"14641","inReplyTo":"1216849332-26813-7-git-send-email-barra_cuda@katamail.com","subject":"Re: [PATCH 6/9] builtin-init-db.c: use parse_options()","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-07-24T16:15:46Z","receivedAt":"2008-07-24T16:15:46Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"Michele Ballabio a écrit :\n> \n> +\tconst struct option options[] = {\n> +\t\tOPT_STRING(0, \"template\", &template_dir, \"dir\",\n> +\t\t\t   \"directory from which templates will be used\"),\n\nPerhaps \"path\", \"path to the template repository\" to stay consistent with clone.\n\n> +\t\tOPT_BOOLEAN(0, \"bare\", &bare, \"set up a bare repo\"),\n\ns/set up/setup/ and s/repo/repository/?\n\n> +\t\t{ OPTION_CALLBACK, 0, \"shared\", &shared_repository,\n> +\t\t  \"type\", \"type of shared repository\",\n\nWhat about \"permissions\", \"setup a shared repository\"?\n\n> +\t\t  PARSE_OPT_OPTARG, parse_opt_shared_cb, PERM_GROUP },\n\nAre you sure the default value is really used here?\n\nAlso, perhaps we can play it safer by avoiding changing \"share_repository\"\ndirectly.\n\n$ git init -> shared_repository == PERM_UMASK\n$ git init --shared --no-shared -> shared_repository == 0\n\nIt works because PERM_UMASK == 0, but it is a side effect. Don't you think?\n\n> +\t\tOPT_BIT('q', \"quiet\", &flags, \"be quiet\", INIT_DB_QUIET),\n\nOPT__QUIET(&quiet),\n\nif (quiet)\n\tflags |= INIT_DB_QUIET;\n\nto use the same quiet option everywhere?\n\nJust my opinion,\nOlivier.\n"},{"id":"84746","messageId":"4888B4E3.9000504@free.fr","threadId":"14641","inReplyTo":"1216849332-26813-2-git-send-email-barra_cuda@katamail.com","subject":"Re: [PATCH 1/9] builtin-verify-tag.c: use parse_options()","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-07-24T16:59:15Z","receivedAt":"2008-07-24T16:59:15Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"Michele Ballabio a écrit :\n> \n>  \tif (argc == 1)\n> -\t\tusage(builtin_verify_tag_usage);\n> +\t\tusage_with_options(builtin_verify_tag_usage, options);\n\nIt seems this is broken since the C rewrite: \"git verify-tag -v\" just do\nnothing instead of printing usage message.\n\nMoving the if() after parse_options() call with s/argc == 1/argc == 0/\nshould do the trick.\n\n> -\tif (!strcmp(argv[i], \"-v\") || !strcmp(argv[i], \"--verbose\")) {\n> -\t\tverbose = 1;\n> -\t\ti++;\n> -\t}\n> +\targc = parse_options(argc, argv, options, builtin_verify_tag_usage, 0);\n\nOlivier.\n"},{"id":"84748","messageId":"alpine.DEB.1.00.0807241801030.8986@racer","threadId":"14641","inReplyTo":"4888AAB2.5050007@free.fr","subject":"Re: [PATCH 6/9] builtin-init-db.c: use parse_options()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-24T17:07:02Z","receivedAt":"2008-07-24T17:07:02Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 24 Jul 2008, Olivier Marin wrote:\n\n> Michele Ballabio a ??rit :\n> \n> > +\t\tOPT_BOOLEAN(0, \"bare\", &bare, \"set up a bare repo\"),\n> \n> s/set up/setup/\n\nNo.  \"setup\" is a noun.\n\n> > +\t\t{ OPTION_CALLBACK, 0, \"shared\", &shared_repository,\n> > +\t\t  \"type\", \"type of shared repository\",\n> \n> What about \"permissions\", \"setup a shared repository\"?\n> \n> > +\t\t  PARSE_OPT_OPTARG, parse_opt_shared_cb, PERM_GROUP },\n> \n> Are you sure the default value is really used here?\n> \n> Also, perhaps we can play it safer by avoiding changing \"share_repository\"\n> directly.\n\nI do not see how that would be any safer.\n\n> $ git init -> shared_repository == PERM_UMASK\n> $ git init --shared --no-shared -> shared_repository == 0\n> \n> It works because PERM_UMASK == 0, but it is a side effect. Don't you think?\n\nThen the callback is wrong, too.  I think, however, that it is by design, \nand correct.\n\nWe rely on shared_repository == 0 for non-shared repositories _almost \neverywhere_.\n\n> > +\t\tOPT_BIT('q', \"quiet\", &flags, \"be quiet\", INIT_DB_QUIET),\n> \n> OPT__QUIET(&quiet),\n> \n> if (quiet)\n> \tflags |= INIT_DB_QUIET;\n> \n> to use the same quiet option everywhere?\n\nWhy?  Doesn't make it more readable, I think.  I'd rather have 3 lines \nless.\n\nCiao,\nDscho\n"},{"id":"84749","messageId":"alpine.DEB.1.00.0807241807550.8986@racer","threadId":"14641","inReplyTo":"4888B4E3.9000504@free.fr","subject":"Re: [PATCH 1/9] builtin-verify-tag.c: use parse_options()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-24T17:08:26Z","receivedAt":"2008-07-24T17:08:26Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 24 Jul 2008, Olivier Marin wrote:\n\n> Michele Ballabio a écrit :\n> > \n> >  \tif (argc == 1)\n> > -\t\tusage(builtin_verify_tag_usage);\n> > +\t\tusage_with_options(builtin_verify_tag_usage, options);\n> \n> It seems this is broken since the C rewrite: \"git verify-tag -v\" just do\n> nothing instead of printing usage message.\n> \n> Moving the if() after parse_options() call with s/argc == 1/argc == 0/\n> should do the trick.\n\nThat would be a bugfix.  As such, it belongs into a different commit.  \nCare to provide a patch?\n\n> > -\tif (!strcmp(argv[i], \"-v\") || !strcmp(argv[i], \"--verbose\")) {\n> > -\t\tverbose = 1;\n> > -\t\ti++;\n> > -\t}\n> > +\targc = parse_options(argc, argv, options, builtin_verify_tag_usage, 0);\n\nWhy did you quote this?\n\nCiao,\nDscho\n"},{"id":"84785","messageId":"200807242207.02195.barra_cuda@katamail.com","threadId":"14641","inReplyTo":"4888AAB2.5050007@free.fr","subject":"Re: [PATCH 6/9] builtin-init-db.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-24T20:07:01Z","receivedAt":"2008-07-24T20:07:01Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"On Thursday 24 July 2008, Olivier Marin wrote:\n> Michele Ballabio a écrit :\n> > \n> > +\tconst struct option options[] = {\n> > +\t\tOPT_STRING(0, \"template\", &template_dir, \"dir\",\n> > +\t\t\t   \"directory from which templates will be used\"),\n> \n> Perhaps \"path\", \"path to the template repository\" to stay consistent with clone.\n\nOk.\n\n> > +\t\tOPT_BOOLEAN(0, \"bare\", &bare, \"set up a bare repo\"),\n> \n> s/set up/setup/ and s/repo/repository/?\n\nI think \"set up a bare repository\" will be fine.\n\n> > +\t\t{ OPTION_CALLBACK, 0, \"shared\", &shared_repository,\n> > +\t\t  \"type\", \"type of shared repository\",\n> \n> What about \"permissions\", \"setup a shared repository\"?\n\nOk, but with s/setup/set up/.\n\n> > +\t\t  PARSE_OPT_OPTARG, parse_opt_shared_cb, PERM_GROUP },\n> \n> Are you sure the default value is really used here?\n\nYes. Perhaps I don't understand your question. Can you explain what you mean?\n\n> Also, perhaps we can play it safer by avoiding changing \"share_repository\"\n> directly.\n> \n> $ git init -> shared_repository == PERM_UMASK\n> $ git init --shared --no-shared -> shared_repository == 0\n> \n> It works because PERM_UMASK == 0, but it is a side effect. Don't you think?\n\nWould you like this better, with PARSE_OPT_NONEG?\n\n+               { OPTION_CALLBACK, 0, \"shared\", &shared_repository,\n+                 \"permissions\", \"set up a shared repository\",\n+                 PARSE_OPT_OPTARG | PARSE_OPT_NONEG, parse_opt_shared_cb, PERM_GROUP },\n\nOr do you prefer changing the callback like this:\n\n+static int parse_opt_shared_cb(const struct option *opt, const char *arg,\n+                              int unset)\n+{\n+       *(int *)(opt->value) = unset ? PERM_UMASK : git_config_perm(\"arg\", arg);\n+       return 0;\n+}\n\n> > +\t\tOPT_BIT('q', \"quiet\", &flags, \"be quiet\", INIT_DB_QUIET),\n> \n> OPT__QUIET(&quiet),\n> \n> if (quiet)\n> \tflags |= INIT_DB_QUIET;\n> \n> to use the same quiet option everywhere?\n\nI thought about it and decided against ;)\nAnd it's one line vs four (counting \"int quiet = 0;\"). But I see your point.\n"},{"id":"84787","messageId":"200807242208.37192.barra_cuda@katamail.com","threadId":"14641","inReplyTo":"alpine.DEB.1.00.0807241543190.8986@racer","subject":"Re: [PATCH 7/9] builtin-checkout-index.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-24T20:08:37Z","receivedAt":"2008-07-24T20:08:37Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"On Thursday 24 July 2008, Johannes Schindelin wrote:\n> On Wed, 23 Jul 2008, Michele Ballabio wrote:\n> \n> > +\t\t{ OPTION_CALLBACK, 'f', \"force\", &state, NULL,\n> > +\t\t  \"force overwrite of existing files\",\n> > +\t\t  PARSE_OPT_NOARG, parse_state_force_cb, 0 },\n> \n> I wonder if this could not be written as\n> \n> \t\tOPT_BOOLEAN('f', \"force\", &state.force,\n> \t\t\t\"force overwrite of existing files\"), \n\nI did it that way because 'force' is a bitfield.\n"},{"id":"84793","messageId":"bd6139dc0807241335i3ab5280aq6a46325428ccc70f@mail.gmail.com","threadId":"14641","inReplyTo":"200807242208.37192.barra_cuda@katamail.com","subject":"Re: [PATCH 7/9] builtin-checkout-index.c: use parse_options()","fromName":"Sverre Rabbelier","fromEmail":"alturin@gmail.com","sentAt":"2008-07-24T20:35:05Z","receivedAt":"2008-07-24T20:35:05Z","isPatch":true,"sender":{"key":"alturin@gmail.com","avatar":null},"body":"On Thu, Jul 24, 2008 at 10:08 PM, Michele Ballabio\n<barra_cuda@katamail.com> wrote:\n> On Thursday 24 July 2008, Johannes Schindelin wrote:\n>> On Wed, 23 Jul 2008, Michele Ballabio wrote:\n>>\n>> > +           { OPTION_CALLBACK, 'f', \"force\", &state, NULL,\n>> > +             \"force overwrite of existing files\",\n>> > +             PARSE_OPT_NOARG, parse_state_force_cb, 0 },\n>>\n>> I wonder if this could not be written as\n>>\n>>               OPT_BOOLEAN('f', \"force\", &state.force,\n>>                       \"force overwrite of existing files\"),\n>\n> I did it that way because 'force' is a bitfield.\n\nI thought there is an OPT_BIT?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"84842","messageId":"200807251015.18143.barra_cuda@katamail.com","threadId":"14641","inReplyTo":"200807242207.02195.barra_cuda@katamail.com","subject":"[PATCH 6/9 - v2] builtin-init-db.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-25T08:15:18Z","receivedAt":"2008-07-25T08:15:18Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\n\nOn Thursday 24 July 2008, Michele Ballabio wrote:\n> +static int parse_opt_shared_cb(const struct option *opt, const char *arg,\n> +                              int unset)\n> +{\n> +       *(int *)(opt->value) = unset ? PERM_UMASK : git_config_perm(\"arg\", arg);\n> +       return 0;\n> +}\n> \n\nDid it this way (and changed help strings).\n\n builtin-init-db.c |   57 +++++++++++++++++++++++++++++++++-------------------\n 1 files changed, 36 insertions(+), 21 deletions(-)\n\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex 38b4fcb..42c2e20 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -6,6 +6,7 @@\n #include \"cache.h\"\n #include \"builtin.h\"\n #include \"exec_cmd.h\"\n+#include \"parse-options.h\"\n \n #ifndef DEFAULT_GIT_TEMPLATE_DIR\n #define DEFAULT_GIT_TEMPLATE_DIR \"/usr/share/git-core/templates\"\n@@ -353,8 +354,18 @@ static int guess_repository_type(const char *git_dir)\n \treturn 1;\n }\n \n-static const char init_db_usage[] =\n-\"git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]]\";\n+static const char * const init_db_usage[] = {\n+\t\"git init [-q | --quiet] [--bare] [--template=<dir>] [--shared[=<type>]]\",\n+\tNULL\n+};\n+\n+static int parse_opt_shared_cb(const struct option *opt, const char *arg,\n+\t\t\t       int unset)\n+{\n+\t*(int *)(opt->value) = unset ? PERM_UMASK :\n+\t\t\t\t       git_config_perm(\"arg\", arg);\n+\treturn 0;\n+}\n \n /*\n  * If you want to, you can share the DB area with any number of branches.\n@@ -367,25 +378,29 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \tconst char *git_dir;\n \tconst char *template_dir = NULL;\n \tunsigned int flags = 0;\n-\tint i;\n-\n-\tfor (i = 1; i < argc; i++, argv++) {\n-\t\tconst char *arg = argv[1];\n-\t\tif (!prefixcmp(arg, \"--template=\"))\n-\t\t\ttemplate_dir = arg+11;\n-\t\telse if (!strcmp(arg, \"--bare\")) {\n-\t\t\tstatic char git_dir[PATH_MAX+1];\n-\t\t\tis_bare_repository_cfg = 1;\n-\t\t\tsetenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir,\n-\t\t\t\t\t\tsizeof(git_dir)), 0);\n-\t\t} else if (!strcmp(arg, \"--shared\"))\n-\t\t\tshared_repository = PERM_GROUP;\n-\t\telse if (!prefixcmp(arg, \"--shared=\"))\n-\t\t\tshared_repository = git_config_perm(\"arg\", arg+9);\n-\t\telse if (!strcmp(arg, \"-q\") || !strcmp(arg, \"--quiet\"))\n-\t\t\tflags |= INIT_DB_QUIET;\n-\t\telse\n-\t\t\tusage(init_db_usage);\n+\tint bare = 0;\n+\n+\tconst struct option options[] = {\n+\t\tOPT_STRING(0, \"template\", &template_dir, \"path\",\n+\t\t\t   \"path to the template directory\"),\n+\t\tOPT_BOOLEAN(0, \"bare\", &bare, \"set up a bare repository\"),\n+\t\t{ OPTION_CALLBACK, 0, \"shared\", &shared_repository,\n+\t\t  \"permissions\", \"set up a shared repository\",\n+\t\t  PARSE_OPT_OPTARG, parse_opt_shared_cb, PERM_GROUP },\n+\t\tOPT_BIT('q', \"quiet\", &flags, \"be quiet\", INIT_DB_QUIET),\n+\t\tOPT_END()\n+\t};\n+\n+\targc = parse_options(argc, argv, options, init_db_usage, 0);\n+\n+\tif (argc > 0)\n+\t\tusage_with_options(init_db_usage, options);\n+\n+\tif (bare) {\n+\t\tstatic char git_dir[PATH_MAX+1];\n+\t\tis_bare_repository_cfg = 1;\n+\t\tsetenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir,\n+\t\t\t\t\tsizeof(git_dir)), 0);\n \t}\n \n \t/*\n-- \n1.5.6.3\n"},{"id":"84852","messageId":"48899657.5090209@lsrfire.ath.cx","threadId":"14641","inReplyTo":"bd6139dc0807241335i3ab5280aq6a46325428ccc70f@mail.gmail.com","subject":"Re: [PATCH 7/9] builtin-checkout-index.c: use parse_options()","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2008-07-25T09:01:11Z","receivedAt":"2008-07-25T09:01:11Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Sverre Rabbelier schrieb:\n> On Thu, Jul 24, 2008 at 10:08 PM, Michele Ballabio\n> <barra_cuda@katamail.com> wrote:\n>> On Thursday 24 July 2008, Johannes Schindelin wrote:\n>>> On Wed, 23 Jul 2008, Michele Ballabio wrote:\n>>>\n>>>> +           { OPTION_CALLBACK, 'f', \"force\", &state, NULL,\n>>>> +             \"force overwrite of existing files\",\n>>>> +             PARSE_OPT_NOARG, parse_state_force_cb, 0 },\n>>> I wonder if this could not be written as\n>>>\n>>>               OPT_BOOLEAN('f', \"force\", &state.force,\n>>>                       \"force overwrite of existing files\"),\n>> I did it that way because 'force' is a bitfield.\n> \n> I thought there is an OPT_BIT?\n\nOPT_BIT is for flags and bitmasks, not for bitfields.\n\nSince you can't get the address of a bitfield member, a function that\nwants to change its value needs to know its name.  Switching to bitmasks\nwould make the option parsing code look cleaner, but you'd have to\nchange all those bitfield accesses to explicit bitmask operations, e.g.:\n\n\tif (state.force)\n\t\tstate.force = 0;\n\nvs.\n\n\tif (state.flags & CHECKOUT_FORCE)\n\t\tstate.flags &= ~CHECKOUT_FORCE;\n\nIn the case of struct checkout, though, we could simply make the\nbitfield members full ints, because there are only a few instances of\nthis structure in memory at any given time.  Wasting a few bytes of RAM\nin order to gain much simpler code is OK in this case, I think.\nOPT_BOOLEAN looks a lot nicer than a callback.\n\nRené\n"},{"id":"84891","messageId":"4889EF22.6020604@free.fr","threadId":"14641","inReplyTo":"alpine.DEB.1.00.0807241807550.8986@racer","subject":"Re: [PATCH 1/9] builtin-verify-tag.c: use parse_options()","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-07-25T15:20:02Z","receivedAt":"2008-07-25T15:20:02Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"Johannes Schindelin a écrit :\n> \n> That would be a bugfix.  As such, it belongs into a different commit.  \n\nI thought, for that kind of trivial bug that probably never hit anyone,\na line in the commit message was enough.\n\n> Care to provide a patch?\n\nOK, will do.\n\nOlivier.\n"},{"id":"84890","messageId":"4889EF3A.6040605@free.fr","threadId":"14641","inReplyTo":"alpine.DEB.1.00.0807241801030.8986@racer","subject":"Re: [PATCH 6/9] builtin-init-db.c: use parse_options()","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-07-25T15:20:26Z","receivedAt":"2008-07-25T15:20:26Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"Johannes Schindelin a écrit :\n>>\n>>> +\t\tOPT_BOOLEAN(0, \"bare\", &bare, \"set up a bare repo\"),\n>> s/set up/setup/\n> \n> No.  \"setup\" is a noun.\n\nRight, sorry.\n\n> We rely on shared_repository == 0 for non-shared repositories _almost \n> everywhere_.\n\nI think we rely on the fact that PERM_UMASK == 0 and not on the value\nof shared_repository. Not the same thing.\n\nThat said, perhaps you are right: it is harmless.\n\n>>> +\t\tOPT_BIT('q', \"quiet\", &flags, \"be quiet\", INIT_DB_QUIET),\n>> OPT__QUIET(&quiet),\n>>\n>> if (quiet)\n>> \tflags |= INIT_DB_QUIET;\n>>\n>> to use the same quiet option everywhere?\n> \n> Why?  Doesn't make it more readable, I think.  I'd rather have 3 lines \n> less.\n\nHum.\n\nOlivier.\n"},{"id":"84892","messageId":"4889EF45.1040603@free.fr","threadId":"14641","inReplyTo":"200807242207.02195.barra_cuda@katamail.com","subject":"Re: [PATCH 6/9] builtin-init-db.c: use parse_options()","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-07-25T15:20:37Z","receivedAt":"2008-07-25T15:20:37Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"Michele Ballabio a écrit :\n> \n>>> +\t\t  PARSE_OPT_OPTARG, parse_opt_shared_cb, PERM_GROUP },\n>> Are you sure the default value is really used here?\n> \n> Yes. Perhaps I don't understand your question. Can you explain what you mean?\n\nIf I read the code correctly in parse-options.c, with OPTION_CALLBACK, the\ndefault value is not \"automatically\" used. You can use it in your callback\nif you want, but because you don't, I think it's never used.\n\n> Would you like this better, with PARSE_OPT_NONEG?\n\nNo, I'm fine with the negated option.\n\n> Or do you prefer changing the callback like this:\n> \n> +static int parse_opt_shared_cb(const struct option *opt, const char *arg,\n> +                              int unset)\n> +{\n> +       *(int *)(opt->value) = unset ? PERM_UMASK : git_config_perm(\"arg\", arg);\n> +       return 0;\n> +}\n\nI think it's better but what I suggested is more something like:\n\nstatic int parse_opt_shared_cb(const struct option *opt, const char *arg,\n\t\t\t       int unset)\n{\n\t*(int *)(opt->value) = unset ? -1 : git_config_perm(\"arg\", arg);\n\treturn 0;\n}\n\nint shared = -1;\n\n{ OPTION_CALLBACK, 0, \"shared\", &shared,\n\t\"permissions\", \"setup as shared repository\",\n\tPARSE_OPT_OPTARG, parse_perm_callback },\n\nif (shared >= 0)\n\tshared_repository = shared;\n\nThis way we do not change shared_repository during parsing, so we do not\nloose the initial value.\n\nBut it seems nobody care about this kind of details, so perhaps, you can\njust ignore this suggestion.\n\nOlivier.\n"},{"id":"84896","messageId":"1217003155-12026-1-git-send-email-barra_cuda@katamail.com","threadId":"14641","inReplyTo":"48899657.5090209@lsrfire.ath.cx","subject":"[PATCH 7/9 - v2] builtin-checkout-index.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-25T16:25:55Z","receivedAt":"2008-07-25T16:25:55Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"This changes \"struct checkout\" (now it uses ints and not bitfields) to\nsimplify the parsing code.\n\nSigned-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\nOn Friday 25 July 2008, RenÃ© Scharfe wrote:\n> In the case of struct checkout, though, we could simply make the\n> bitfield members full ints, because there are only a few instances of\n> this structure in memory at any given time. Wasting a few bytes of RAM\n> in order to gain much simpler code is OK in this case, I think.\n> OPT_BOOLEAN looks a lot nicer than a callback.\n\nYes. I only wanted the changes to be minimal, and only affect the option\nparsing. In this sense, I still think the old patch is better. Here it is\nthe one you suggested (maybe Johannes suggested the same, but I didn't\nunderstand :).\n\n builtin-checkout-index.c |  113 +++++++++++++++++++---------------------------\n cache.h                  |    8 ++--\n 2 files changed, 50 insertions(+), 71 deletions(-)\n\ndiff --git a/builtin-checkout-index.c b/builtin-checkout-index.c\nindex 71ebabf..135348e 100644\n--- a/builtin-checkout-index.c\n+++ b/builtin-checkout-index.c\n@@ -40,6 +40,7 @@\n #include \"cache.h\"\n #include \"quote.h\"\n #include \"cache-tree.h\"\n+#include \"parse-options.h\"\n \n #define CHECKOUT_ALL 4\n static int line_termination = '\\n';\n@@ -153,18 +154,43 @@ static void checkout_all(const char *prefix, int prefix_length)\n \t\texit(128);\n }\n \n-static const char checkout_cache_usage[] =\n-\"git checkout-index [-u] [-q] [-a] [-f] [-n] [--stage=[123]|all] [--prefix=<string>] [--temp] [--] <file>...\";\n+static const char * const checkout_cache_usage[] = {\n+\t\"git checkout-index [options] [--] <file>...\",\n+\tNULL\n+};\n \n static struct lock_file lock_file;\n \n int cmd_checkout_index(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n \tint newfd = -1;\n \tint all = 0;\n \tint read_from_stdin = 0;\n \tint prefix_length;\n+\tchar *stage = NULL;\n+\n+\tconst struct option options[] = {\n+\t\tOPT_BOOLEAN('a', \"all\", &all,\n+\t\t\t    \"checks out all files in the index\"),\n+\t\tOPT_BOOLEAN('f', \"force\", &state.force,\n+\t\t\t    \"force overwrite of existing files\"),\n+\t\tOPT__QUIET(&state.quiet),\n+\t\tOPT_SET_INT('n', \"no-create\", &state.not_new,\n+\t\t\t\"do not checkout new files, refresh existing ones\", 1),\n+\t\tOPT_BOOLEAN('u', \"index\", &state.refresh_cache,\n+\t\t\t    \"update stat information in the index\"),\n+\t\tOPT_SET_INT('z', NULL, &line_termination,\n+\t\t\t    \"separate paths with NUL\", 0),\n+\t\tOPT_BOOLEAN(0, \"stdin\", &read_from_stdin,\n+\t\t\t    \"read paths from stdin\"),\n+\t\tOPT_BOOLEAN(0, \"temp\", &to_tempfile,\n+\t\t\t    \"write content to temporary files\"),\n+\t\tOPT_STRING(0, \"prefix\", &state.base_dir, \"string\",\n+\t\t\t   \"prepend <string> when creating files\"),\n+\t\tOPT_STRING(0, \"stage\", &stage, \"1|2|3|all\",\n+\t\t\t   \"copy out files from the named stage\"),\n+\t\tOPT_END()\n+\t};\n \n \tgit_config(git_default_config, NULL);\n \tstate.base_dir = \"\";\n@@ -174,71 +200,24 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)\n \t\tdie(\"invalid cache\");\n \t}\n \n-\tfor (i = 1; i < argc; i++) {\n-\t\tconst char *arg = argv[i];\n+\targc = parse_options(argc, argv, options, checkout_cache_usage, 0);\n \n-\t\tif (!strcmp(arg, \"--\")) {\n-\t\t\ti++;\n-\t\t\tbreak;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-a\") || !strcmp(arg, \"--all\")) {\n-\t\t\tall = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-f\") || !strcmp(arg, \"--force\")) {\n-\t\t\tstate.force = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-q\") || !strcmp(arg, \"--quiet\")) {\n-\t\t\tstate.quiet = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-n\") || !strcmp(arg, \"--no-create\")) {\n-\t\t\tstate.not_new = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-u\") || !strcmp(arg, \"--index\")) {\n-\t\t\tstate.refresh_cache = 1;\n-\t\t\tif (newfd < 0)\n-\t\t\t\tnewfd = hold_locked_index(&lock_file, 1);\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-z\")) {\n-\t\t\tline_termination = 0;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--stdin\")) {\n-\t\t\tif (i != argc - 1)\n-\t\t\t\tdie(\"--stdin must be at the end\");\n-\t\t\tread_from_stdin = 1;\n-\t\t\ti++; /* do not consider arg as a file name */\n-\t\t\tbreak;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--temp\")) {\n+\tif ((state.refresh_cache) && (newfd < 0))\n+\t\tnewfd = hold_locked_index(&lock_file, 1);\n+\tif (state.base_dir)\n+\t\tstate.base_dir_len = strlen(state.base_dir);\n+\n+\tif (stage) {\n+\t\tif (!strcmp(stage, \"all\")) {\n \t\t\tto_tempfile = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!prefixcmp(arg, \"--prefix=\")) {\n-\t\t\tstate.base_dir = arg+9;\n-\t\t\tstate.base_dir_len = strlen(state.base_dir);\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!prefixcmp(arg, \"--stage=\")) {\n-\t\t\tif (!strcmp(arg + 8, \"all\")) {\n-\t\t\t\tto_tempfile = 1;\n-\t\t\t\tcheckout_stage = CHECKOUT_ALL;\n-\t\t\t} else {\n-\t\t\t\tint ch = arg[8];\n-\t\t\t\tif ('1' <= ch && ch <= '3')\n-\t\t\t\t\tcheckout_stage = arg[8] - '0';\n-\t\t\t\telse\n-\t\t\t\t\tdie(\"stage should be between 1 and 3 or all\");\n-\t\t\t}\n-\t\t\tcontinue;\n+\t\t\tcheckout_stage = CHECKOUT_ALL;\n+\t\t} else {\n+\t\t\tint ch = stage[0];\n+\t\t\tif ('1' <= ch && ch <= '3')\n+\t\t\t\tcheckout_stage = stage[0] - '0';\n+\t\t\telse\n+\t\t\t\tdie(\"stage should be between 1 and 3 or all\");\n \t\t}\n-\t\tif (arg[0] == '-')\n-\t\t\tusage(checkout_cache_usage);\n-\t\tbreak;\n \t}\n \n \tif (state.base_dir_len || to_tempfile) {\n@@ -253,8 +232,8 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)\n \t}\n \n \t/* Check out named files first */\n-\tfor ( ; i < argc; i++) {\n-\t\tconst char *arg = argv[i];\n+\twhile (argc-- > 0) {\n+\t\tconst char *arg = *argv++;\n \t\tconst char *p;\n \n \t\tif (all)\ndiff --git a/cache.h b/cache.h\nindex 38985aa..0bbe33b 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -618,10 +618,10 @@ extern const char *fmt_name(const char *name, const char *email);\n struct checkout {\n \tconst char *base_dir;\n \tint base_dir_len;\n-\tunsigned force:1,\n-\t\t quiet:1,\n-\t\t not_new:1,\n-\t\t refresh_cache:1;\n+\tint force;\n+\tint quiet;\n+\tint not_new;\n+\tint refresh_cache;\n };\n \n extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath);\n-- \n1.5.6.3\n"},{"id":"84935","messageId":"1217015608-26205-1-git-send-email-barra_cuda@katamail.com","threadId":"14641","inReplyTo":"4889EF45.1040603@free.fr","subject":"[PATCH 6/9 - v3] builtin-init-db.c: use parse_options()","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-07-25T19:53:28Z","receivedAt":"2008-07-25T19:53:28Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\nOn Friday 25 July 2008, Olivier Marin wrote:\n> Michele Ballabio a Ã©crit :\n> > \n> >>> +\t\t  PARSE_OPT_OPTARG, parse_opt_shared_cb, PERM_GROUP },\n> >> Are you sure the default value is really used here?\n> > \n> > Yes. Perhaps I don't understand your question. Can you explain what you mean?\n> \n> If I read the code correctly in parse-options.c, with OPTION_CALLBACK, the\n> default value is not \"automatically\" used. You can use it in your callback\n> if you want, but because you don't, I think it's never used.\n\nOh, you're right, but git_config_perm() handles NULL just fine, so I can\nremove it. Done in this patch, thanks.\n\n> what I suggested is more something like:\n> \n> static int parse_opt_shared_cb(const struct option *opt, const char *arg,\n> \t\t\t       int unset)\n> {\n> \t*(int *)(opt->value) = unset ? -1 : git_config_perm(\"arg\", arg);\n> \treturn 0;\n> }\n> \n> int shared = -1;\n> \n> { OPTION_CALLBACK, 0, \"shared\", &shared,\n> \t\"permissions\", \"setup as shared repository\",\n> \tPARSE_OPT_OPTARG, parse_perm_callback },\n> \n> if (shared >= 0)\n> \tshared_repository = shared;\n> \n> This way we do not change shared_repository during parsing, so we do not\n> loose the initial value.\n> \n> But it seems nobody care about this kind of details, so perhaps, you can\n> just ignore this suggestion.\n\nI might be wrong, but shared_repository is initialized to PERM_UMASK and\ndoes not change before parse_options() is called, so this is not much\nuseful.\n\n builtin-init-db.c |   57 +++++++++++++++++++++++++++++++++-------------------\n 1 files changed, 36 insertions(+), 21 deletions(-)\n\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex 38b4fcb..01b84a9 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -6,6 +6,7 @@\n #include \"cache.h\"\n #include \"builtin.h\"\n #include \"exec_cmd.h\"\n+#include \"parse-options.h\"\n \n #ifndef DEFAULT_GIT_TEMPLATE_DIR\n #define DEFAULT_GIT_TEMPLATE_DIR \"/usr/share/git-core/templates\"\n@@ -353,8 +354,18 @@ static int guess_repository_type(const char *git_dir)\n \treturn 1;\n }\n \n-static const char init_db_usage[] =\n-\"git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]]\";\n+static const char * const init_db_usage[] = {\n+\t\"git init [-q | --quiet] [--bare] [--template=<dir>] [--shared[=<type>]]\",\n+\tNULL\n+};\n+\n+static int parse_opt_shared_cb(const struct option *opt, const char *arg,\n+\t\t\t       int unset)\n+{\n+\t*(int *)(opt->value) = unset ? PERM_UMASK :\n+\t\t\t\t       git_config_perm(\"arg\", arg);\n+\treturn 0;\n+}\n \n /*\n  * If you want to, you can share the DB area with any number of branches.\n@@ -367,25 +378,29 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \tconst char *git_dir;\n \tconst char *template_dir = NULL;\n \tunsigned int flags = 0;\n-\tint i;\n-\n-\tfor (i = 1; i < argc; i++, argv++) {\n-\t\tconst char *arg = argv[1];\n-\t\tif (!prefixcmp(arg, \"--template=\"))\n-\t\t\ttemplate_dir = arg+11;\n-\t\telse if (!strcmp(arg, \"--bare\")) {\n-\t\t\tstatic char git_dir[PATH_MAX+1];\n-\t\t\tis_bare_repository_cfg = 1;\n-\t\t\tsetenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir,\n-\t\t\t\t\t\tsizeof(git_dir)), 0);\n-\t\t} else if (!strcmp(arg, \"--shared\"))\n-\t\t\tshared_repository = PERM_GROUP;\n-\t\telse if (!prefixcmp(arg, \"--shared=\"))\n-\t\t\tshared_repository = git_config_perm(\"arg\", arg+9);\n-\t\telse if (!strcmp(arg, \"-q\") || !strcmp(arg, \"--quiet\"))\n-\t\t\tflags |= INIT_DB_QUIET;\n-\t\telse\n-\t\t\tusage(init_db_usage);\n+\tint bare = 0;\n+\n+\tconst struct option options[] = {\n+\t\tOPT_STRING(0, \"template\", &template_dir, \"path\",\n+\t\t\t   \"path to the template directory\"),\n+\t\tOPT_BOOLEAN(0, \"bare\", &bare, \"set up a bare repository\"),\n+\t\t{ OPTION_CALLBACK, 0, \"shared\", &shared_repository,\n+\t\t  \"permissions\", \"set up a shared repository\",\n+\t\t  PARSE_OPT_OPTARG, parse_opt_shared_cb },\n+\t\tOPT_BIT('q', \"quiet\", &flags, \"be quiet\", INIT_DB_QUIET),\n+\t\tOPT_END()\n+\t};\n+\n+\targc = parse_options(argc, argv, options, init_db_usage, 0);\n+\n+\tif (argc > 0)\n+\t\tusage_with_options(init_db_usage, options);\n+\n+\tif (bare) {\n+\t\tstatic char git_dir[PATH_MAX+1];\n+\t\tis_bare_repository_cfg = 1;\n+\t\tsetenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir,\n+\t\t\t\t\tsizeof(git_dir)), 0);\n \t}\n \n \t/*\n-- \n1.5.6.3\n"},{"id":"84973","messageId":"alpine.DEB.1.00.0807260252520.11976@eeepc-johanness","threadId":"14641","inReplyTo":"4889EF22.6020604@free.fr","subject":"Re: [PATCH 1/9] builtin-verify-tag.c: use parse_options()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-26T00:53:16Z","receivedAt":"2008-07-26T00:53:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 25 Jul 2008, Olivier Marin wrote:\n\n> Johannes Schindelin a écrit :\n> > \n> > That would be a bugfix.  As such, it belongs into a different commit.  \n> \n> I thought, for that kind of trivial bug that probably never hit anyone, \n> a line in the commit message was enough.\n\nSo bisectability goes down the gutter?"},{"id":"84974","messageId":"alpine.DEB.1.00.0807260254010.11976@eeepc-johanness","threadId":"14641","inReplyTo":"4889EF3A.6040605@free.fr","subject":"Re: [PATCH 6/9] builtin-init-db.c: use parse_options()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-26T00:55:17Z","receivedAt":"2008-07-26T00:55:17Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 25 Jul 2008, Olivier Marin wrote:\n\n> Johannes Schindelin a écrit :\n> \n> > We rely on shared_repository == 0 for non-shared repositories _almost \n> > everywhere_.\n> \n> I think we rely on the fact that PERM_UMASK == 0 and not on the value of \n> shared_repository. Not the same thing.\n\nJust look at all the cases where we ask for \"if (shared_repository)\".  \nAnd then look where PERM_UMASK is assigned to.  It _is_ the same thing.\n\nHth,\nDscho\n"},{"id":"85268","messageId":"488DA40C.8020400@free.fr","threadId":"14641","inReplyTo":"4889EF22.6020604@free.fr","subject":"[PATCH] builtin-verify-tag: fix -v option parsing","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-07-28T10:48:44Z","receivedAt":"2008-07-28T10:48:44Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"From: Olivier Marin <dkr@freesurf.fr>\n\nSince the C rewrite, \"git verify-tag -v\" just does nothing instead of\nprinting the usage message with an error. This patch fix the regression.\n\nSigned-off-by: Olivier Marin <dkr@freesurf.fr>\n---\n builtin-verify-tag.c |    9 +++++----\n 1 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin-verify-tag.c b/builtin-verify-tag.c\nindex 7d837f0..729a159 100644\n--- a/builtin-verify-tag.c\n+++ b/builtin-verify-tag.c\n@@ -92,14 +92,15 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)\n \n \tgit_config(git_default_config, NULL);\n \n-\tif (argc == 1)\n-\t\tusage(builtin_verify_tag_usage);\n-\n-\tif (!strcmp(argv[i], \"-v\") || !strcmp(argv[i], \"--verbose\")) {\n+\tif (argc > 1 &&\n+\t    (!strcmp(argv[i], \"-v\") || !strcmp(argv[i], \"--verbose\"))) {\n \t\tverbose = 1;\n \t\ti++;\n \t}\n \n+\tif (argc <= i)\n+\t\tusage(builtin_verify_tag_usage);\n+\n \t/* sometimes the program was terminated because this signal\n \t * was received in the process of writing the gpg input: */\n \tsignal(SIGPIPE, SIG_IGN);\n-- \n1.6.0.rc0.79.gb0320\n"},{"id":"85272","messageId":"alpine.DEB.1.00.0807281306090.2725@eeepc-johanness","threadId":"14641","inReplyTo":"488DA40C.8020400@free.fr","subject":"Re: [PATCH] builtin-verify-tag: fix -v option parsing","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-28T11:06:44Z","receivedAt":"2008-07-28T11:06:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 28 Jul 2008, Olivier Marin wrote:\n\n> From: Olivier Marin <dkr@freesurf.fr>\n> \n> Since the C rewrite, \"git verify-tag -v\" just does nothing instead of \n> printing the usage message with an error. This patch fix the regression.\n\nMaybe a better solution would be to convert (trivially) to \nparse-options...\n\nCiao,\nDscho\n"},{"id":"85278","messageId":"488DB0BD.2060406@free.fr","threadId":"14641","inReplyTo":"alpine.DEB.1.00.0807281306090.2725@eeepc-johanness","subject":"Re: [PATCH] builtin-verify-tag: fix -v option parsing","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-07-28T11:42:53Z","receivedAt":"2008-07-28T11:42:53Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"Johannes Schindelin a écrit :\n>>\n>> Since the C rewrite, \"git verify-tag -v\" just does nothing instead of \n>> printing the usage message with an error. This patch fix the regression.\n> \n> Maybe a better solution would be to convert (trivially) to \n> parse-options...\n\nI am very puzzled.\n\nYou first asked me to do a separate commit with just the fix and now\nyou seem to want the fix with the conversion...\n\nWhat do you mean by \"trivially\"?\n\nOlivier.\n"},{"id":"85282","messageId":"alpine.DEB.1.00.0807281408270.2725@eeepc-johanness","threadId":"14641","inReplyTo":"488DB0BD.2060406@free.fr","subject":"Re: [PATCH] builtin-verify-tag: fix -v option parsing","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-28T12:10:22Z","receivedAt":"2008-07-28T12:10:22Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 28 Jul 2008, Olivier Marin wrote:\n\n> Johannes Schindelin a écrit :\n> >>\n> >> Since the C rewrite, \"git verify-tag -v\" just does nothing instead of \n> >> printing the usage message with an error. This patch fix the \n> >> regression.\n> > \n> > Maybe a better solution would be to convert (trivially) to \n> > parse-options...\n> \n> I am very puzzled.\n> \n> You first asked me to do a separate commit with just the fix and now you \n> seem to want the fix with the conversion...\n\nSorry.  It was not obvious to myself when I asked for a separate patch \nthat the fix would fall out of the conversion to parse-options.\n\nMy fault,\nDscho"}]}