Diff options
Diffstat (limited to 'source/ui-diff.c')
| -rw-r--r-- | source/ui-diff.c | 15 |
1 file changed, 13 insertions, 2 deletions
diff --git a/source/ui-diff.c b/source/ui-diff.c index c696ab1..2974744 100644 --- a/source/ui-diff.c +++ b/source/ui-diff.c @@ -178,12 +178,23 @@ static void count_diff_lines(char *line, int len) render_line_fn(line, len); } +/* + * A path is kept when it is the prefix itself or lies below it, as the + * pathspec of a diff that does not follow would match it. + */ +static int path_in_prefix(const char *path, const char *prefix) +{ + const char *rest; + + return skip_prefix(path, prefix, &rest) && (!*rest || *rest == '/'); +} + static int show_filepair(struct diff_filepair *pair) { if (!current_prefix) return 1; - return starts_with(pair->one->path, current_prefix) || - starts_with(pair->two->path, current_prefix); + return path_in_prefix(pair->one->path, current_prefix) || + path_in_prefix(pair->two->path, current_prefix); } static void print_line(char *line, int len) |
