diff options
Diffstat (limited to 'builtin/ls-tree.c')
-rw-r--r-- | builtin/ls-tree.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c index 209d2dc..7bf84b2 100644 --- a/builtin/ls-tree.c +++ b/builtin/ls-tree.c @@ -9,9 +9,7 @@ #include "hex.h" #include "object-name.h" #include "object-store-ll.h" -#include "blob.h" #include "tree.h" -#include "commit.h" #include "path.h" #include "quote.h" #include "parse-options.h" @@ -102,19 +100,12 @@ static int show_tree_fmt(const struct object_id *oid, struct strbuf *base, return 0; while (strbuf_expand_step(&sb, &format)) { - const char *end; size_t len; if (skip_prefix(format, "%", &format)) strbuf_addch(&sb, '%'); else if ((len = strbuf_expand_literal(&sb, format))) format += len; - else if (*format != '(') - die(_("bad ls-tree format: element '%s' " - "does not start with '('"), format); - else if (!(end = strchr(format + 1, ')'))) - die(_("bad ls-tree format: element '%s' " - "does not end in ')'"), format); else if (skip_prefix(format, "(objectmode)", &format)) strbuf_addf(&sb, "%06o", mode); else if (skip_prefix(format, "(objecttype)", &format)) @@ -137,8 +128,7 @@ static int show_tree_fmt(const struct object_id *oid, struct strbuf *base, strbuf_setlen(base, baselen); strbuf_release(&sbuf); } else - die(_("bad ls-tree format: %%%.*s"), - (int)(end - format + 1), format); + strbuf_expand_bad_format(format, "ls-tree"); } strbuf_addch(&sb, options->null_termination ? '\0' : '\n'); fwrite(sb.buf, sb.len, 1, stdout); @@ -377,6 +367,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix) OPT_END() }; struct ls_tree_cmdmode_to_fmt *m2f = ls_tree_cmdmode_format; + struct object_context obj_context; int ret; git_config(git_default_config, NULL); @@ -408,7 +399,9 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix) ls_tree_usage, ls_tree_options); if (argc < 1) usage_with_options(ls_tree_usage, ls_tree_options); - if (repo_get_oid(the_repository, argv[0], &oid)) + if (get_oid_with_context(the_repository, argv[0], + GET_OID_HASH_ANY, &oid, + &obj_context)) die("Not a valid object name %s", argv[0]); /* |