diff --git a/builtin/repo.c b/builtin/repo.c index 0dd41b1778..1cd12e7eea 100644 --- a/builtin/repo.c +++ b/builtin/repo.c @@ -23,6 +23,7 @@ static const char *const repo_usage[] = { typedef int get_value_fn(struct repository *repo, struct strbuf *buf); enum output_format { + FORMAT_DEFAULT, FORMAT_TABLE, FORMAT_KEYVALUE, FORMAT_NUL_TERMINATED, @@ -159,6 +160,8 @@ static int parse_format_cb(const struct option *opt, *format = FORMAT_KEYVALUE; else if (!strcmp(arg, "table")) *format = FORMAT_TABLE; + else if (!strcmp(arg, "default")) + *format = FORMAT_DEFAULT; else die(_("invalid format '%s'"), arg); @@ -168,7 +171,7 @@ static int parse_format_cb(const struct option *opt, static int cmd_repo_info(int argc, const char **argv, const char *prefix, struct repository *repo) { - enum output_format format = FORMAT_KEYVALUE; + enum output_format format = FORMAT_DEFAULT; int all_keys = 0; struct option options[] = { OPT_CALLBACK_F(0, "format", &format, N_("format"), @@ -183,6 +186,10 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix, }; argc = parse_options(argc, argv, prefix, options, repo_usage, 0); + + if (format == FORMAT_DEFAULT) + format = FORMAT_KEYVALUE; + if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED) die(_("unsupported output format"));