diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-06-21 01:53:13 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-06-21 01:53:13 +0300 |
commit | de00f4b7f3fd3aca18e4bea286bf060c595efd3b (patch) | |
tree | 48131ebe8ff1e9980da040c9afa61b738995769b /pathspec.c | |
parent | 7cb4274d2606775b0d5b373756f76f386a31bb64 (diff) | |
parent | 8260bc59023136edeaed1f1006a03f44cc849883 (diff) |
Merge branch 'jk/log-follow-with-non-literal-pathspec'
"git [-c log.follow=true] log [--follow] ':(glob)f**'" used to barf.
* jk/log-follow-with-non-literal-pathspec:
diff: detect pathspec magic not supported by --follow
diff: factor out --follow pathspec check
pathspec: factor out magic-to-name function
Diffstat (limited to 'pathspec.c')
-rw-r--r-- | pathspec.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/pathspec.c b/pathspec.c index 6966b265d3..5049dbb528 100644 --- a/pathspec.c +++ b/pathspec.c @@ -531,24 +531,29 @@ static int pathspec_item_cmp(const void *a_, const void *b_) return strcmp(a->match, b->match); } -static void NORETURN unsupported_magic(const char *pattern, - unsigned magic) +void pathspec_magic_names(unsigned magic, struct strbuf *out) { - struct strbuf sb = STRBUF_INIT; int i; for (i = 0; i < ARRAY_SIZE(pathspec_magic); i++) { const struct pathspec_magic *m = pathspec_magic + i; if (!(magic & m->bit)) continue; - if (sb.len) - strbuf_addstr(&sb, ", "); + if (out->len) + strbuf_addstr(out, ", "); if (m->mnemonic) - strbuf_addf(&sb, _("'%s' (mnemonic: '%c')"), + strbuf_addf(out, _("'%s' (mnemonic: '%c')"), m->name, m->mnemonic); else - strbuf_addf(&sb, "'%s'", m->name); + strbuf_addf(out, "'%s'", m->name); } +} + +static void NORETURN unsupported_magic(const char *pattern, + unsigned magic) +{ + struct strbuf sb = STRBUF_INIT; + pathspec_magic_names(magic, &sb); /* * We may want to substitute "this command" with a command * name. E.g. when "git add -p" or "git add -i" dies when running |