summaryrefslogtreecommitdiff
path: root/builtin-mktree.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-05-10 10:31:56 -0700
committerJunio C Hamano <gitster@pobox.com>2009-05-10 12:41:35 -0700
commit1fdee85c8844a2cbfdf2f4c0a9c0964b78beb37e (patch)
tree59adcf9880913d53b33d7e2bf79ebe00f59f619d /builtin-mktree.c
parent633e3556ccbcc7e443f5e9194c4a830181696ef0 (diff)
downloadgit-1fdee85c8844a2cbfdf2f4c0a9c0964b78beb37e.tar.gz
mktree: use parse-options
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-mktree.c')
-rw-r--r--builtin-mktree.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/builtin-mktree.c b/builtin-mktree.c
index 3d054272d5..2b3145bc72 100644
--- a/builtin-mktree.c
+++ b/builtin-mktree.c
@@ -6,6 +6,7 @@
#include "builtin.h"
#include "quote.h"
#include "tree.h"
+#include "parse-options.h"
static struct treeent {
unsigned mode;
@@ -61,7 +62,10 @@ static void write_tree(unsigned char *sha1)
write_sha1_file(buf.buf, buf.len, tree_type, sha1);
}
-static const char mktree_usage[] = "git mktree [-z]";
+static const char *mktree_usage[] = {
+ "git mktree [-z]",
+ NULL
+};
int cmd_mktree(int ac, const char **av, const char *prefix)
{
@@ -69,16 +73,12 @@ int cmd_mktree(int ac, const char **av, const char *prefix)
struct strbuf p_uq = STRBUF_INIT;
unsigned char sha1[20];
int line_termination = '\n';
+ const struct option option[] = {
+ OPT_SET_INT('z', NULL, &line_termination, "input is NUL terminated", '\0'),
+ OPT_END()
+ };
- while ((1 < ac) && av[1][0] == '-') {
- const char *arg = av[1];
- if (!strcmp("-z", arg))
- line_termination = 0;
- else
- usage(mktree_usage);
- ac--;
- av++;
- }
+ ac = parse_options(ac, av, option, mktree_usage, 0);
while (strbuf_getline(&sb, stdin, line_termination) != EOF) {
char *ptr, *ntr;