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
This commit is contained in:
29
diff.c
29
diff.c
@ -4751,6 +4751,31 @@ unsigned diff_filter_bit(char status)
|
||||
return filter_bit[(int) status];
|
||||
}
|
||||
|
||||
int diff_check_follow_pathspec(struct pathspec *ps, int die_on_error)
|
||||
{
|
||||
unsigned forbidden_magic;
|
||||
|
||||
if (ps->nr != 1) {
|
||||
if (die_on_error)
|
||||
die(_("--follow requires exactly one pathspec"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
forbidden_magic = ps->items[0].magic & ~(PATHSPEC_FROMTOP |
|
||||
PATHSPEC_LITERAL);
|
||||
if (forbidden_magic) {
|
||||
if (die_on_error) {
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
pathspec_magic_names(forbidden_magic, &sb);
|
||||
die(_("pathspec magic not supported by --follow: %s"),
|
||||
sb.buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void diff_setup_done(struct diff_options *options)
|
||||
{
|
||||
unsigned check_mask = DIFF_FORMAT_NAME |
|
||||
@ -4858,8 +4883,8 @@ void diff_setup_done(struct diff_options *options)
|
||||
|
||||
options->diff_path_counter = 0;
|
||||
|
||||
if (options->flags.follow_renames && options->pathspec.nr != 1)
|
||||
die(_("--follow requires exactly one pathspec"));
|
||||
if (options->flags.follow_renames)
|
||||
diff_check_follow_pathspec(&options->pathspec, 1);
|
||||
|
||||
if (!options->use_color || external_diff())
|
||||
options->color_moved = 0;
|
||||
|
||||
Reference in New Issue
Block a user