@matheusbsbs / matheus-bagliano / commits / 1fdee85c88
Fork 0

mktree: use parse-options

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed May 10, 2009 at 10:31 UTC 1fdee85c8844a2cbfdf2f4c0a9c0964b78beb37e
1 file changed +10 -10
builtin-mktree.c
+10 -10
@@ -6,6 +6,7 @@
6 #include "builtin.h"
7 #include "quote.h"
8 #include "tree.h"
9 +#include "parse-options.h"
10
11 static struct treeent {
12 unsigned mode;
@@ -61,7 +62,10 @@ static void write_tree(unsigned char *sha1)
62 write_sha1_file(buf.buf, buf.len, tree_type, sha1);
63 }
64
64 -static const char mktree_usage[] = "git mktree [-z]";
65 +static const char *mktree_usage[] = {
66 + "git mktree [-z]",
67 + NULL
68 +};
69
70 int cmd_mktree(int ac, const char **av, const char *prefix)
71 {
@@ -69,16 +73,12 @@ int cmd_mktree(int ac, const char **av, const char *prefix)
73 struct strbuf p_uq = STRBUF_INIT;
74 unsigned char sha1[20];
75 int line_termination = '\n';
76 + const struct option option[] = {
77 + OPT_SET_INT('z', NULL, &line_termination, "input is NUL terminated", '\0'),
78 + OPT_END()
79 + };
80
73 - while ((1 < ac) && av[1][0] == '-') {
74 - const char *arg = av[1];
75 - if (!strcmp("-z", arg))
76 - line_termination = 0;
77 - else
78 - usage(mktree_usage);
79 - ac--;
80 - av++;
81 - }
81 + ac = parse_options(ac, av, option, mktree_usage, 0);
82
83 while (strbuf_getline(&sb, stdin, line_termination) != EOF) {
84 char *ptr, *ntr;