Signed-off-by: Michele Ballabio <barra_cuda@xxxxxxxxxxxx> --- builtin-write-tree.c | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) diff --git a/builtin-write-tree.c b/builtin-write-tree.c index 52a3c01..25f3d8a 100644 --- a/builtin-write-tree.c +++ b/builtin-write-tree.c @@ -7,9 +7,12 @@ #include "cache.h" #include "tree.h" #include "cache-tree.h" +#include "parse-options.h" -static const char write_tree_usage[] = -"git write-tree [--missing-ok] [--prefix=<prefix>/]"; +static const char * const write_tree_usage[] = { + "git write-tree [--missing-ok] [--prefix=<directory>/]", + NULL +}; int cmd_write_tree(int argc, const char **argv, const char *unused_prefix) { @@ -19,19 +22,19 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix) const char *me = "git-write-tree"; git_config(git_default_config, NULL); - while (1 < argc) { - const char *arg = argv[1]; - if (!strcmp(arg, "--missing-ok")) - missing_ok = 1; - else if (!prefixcmp(arg, "--prefix=")) - prefix = arg + 9; - else - usage(write_tree_usage); - argc--; argv++; - } - if (argc > 2) - die("too many options"); + const struct option options[] = { + OPT_BOOLEAN(0, "missing-ok", &missing_ok, + "disable existence check"), + OPT_STRING(0, "prefix", &prefix, "directory", + "write a tree object for <directory>"), + OPT_END() + }; + + argc = parse_options(argc, argv, options, write_tree_usage, 0); + + if (argc > 0) + usage_with_options(write_tree_usage, options); ret = write_cache_as_tree(sha1, missing_ok, prefix); switch (ret) { -- 1.5.6.3 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html