diff options
author | René Scharfe <l.s.r@web.de> | 2024-03-24 11:19:40 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-03-25 18:59:24 (GMT) |
commit | e36091aa1d67cedba02ea9de9245f0ff14a52f15 (patch) | |
tree | f3bca1f45a8d8f54955acda7ff517f6432dc30e3 /builtin/ls-files.c | |
parent | 3c2a3fdc388747b9eaf4a4a4f2035c1c9ddb26d0 (diff) | |
download | git-e36091aa1d67cedba02ea9de9245f0ff14a52f15.zip git-e36091aa1d67cedba02ea9de9245f0ff14a52f15.tar.gz git-e36091aa1d67cedba02ea9de9245f0ff14a52f15.tar.bz2 |
factor out strbuf_expand_bad_format()
Extract a function for reporting placeholders that are not enclosed in a
parenthesis or are unknown. This reduces the number of strings to
translate and improves consistency across commands. Call it at the end
of the if/else chain, after exhausting all accepted possibilities.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/ls-files.c')
-rw-r--r-- | builtin/ls-files.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 92f94e6..6eeb5cb 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -266,7 +266,6 @@ static void show_ce_fmt(struct repository *repo, const struct cache_entry *ce, struct strbuf sb = STRBUF_INIT; while (strbuf_expand_step(&sb, &format)) { - const char *end; size_t len; struct stat st; @@ -274,12 +273,6 @@ static void show_ce_fmt(struct repository *repo, const struct cache_entry *ce, strbuf_addch(&sb, '%'); else if ((len = strbuf_expand_literal(&sb, format))) format += len; - else if (*format != '(') - die(_("bad ls-files format: element '%s' " - "does not start with '('"), format); - else if (!(end = strchr(format + 1, ')'))) - die(_("bad ls-files format: element '%s' " - "does not end in ')'"), format); else if (skip_prefix(format, "(objectmode)", &format)) strbuf_addf(&sb, "%06o", ce->ce_mode); else if (skip_prefix(format, "(objectname)", &format)) @@ -308,8 +301,7 @@ static void show_ce_fmt(struct repository *repo, const struct cache_entry *ce, else if (skip_prefix(format, "(path)", &format)) write_name_to_buf(&sb, fullname); else - die(_("bad ls-files format: %%%.*s"), - (int)(end - format + 1), format); + strbuf_expand_bad_format(format, "ls-files"); } strbuf_addch(&sb, line_terminator); fwrite(sb.buf, sb.len, 1, stdout); |