Skip to content

Commit

Permalink
mktree: use parse-options
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed May 10, 2009
1 parent 633e355 commit 1fdee85
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions builtin-mktree.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "builtin.h"
#include "quote.h"
#include "tree.h"
#include "parse-options.h"

static struct treeent {
unsigned mode;
Expand Down Expand Up @@ -61,24 +62,23 @@ 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)
{
struct strbuf sb = STRBUF_INIT;
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;
Expand Down

0 comments on commit 1fdee85

Please sign in to comment.