From: Junio C Hamano Date: Tue, 13 Nov 2018 13:37:28 +0000 (+0900) Subject: Merge branch 'nd/tree-walk-path-exclusion' X-Git-Tag: v2.20.0-rc0~30 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/1e4a714e689e14726982941d8e61db06c6c7d58d?ds=inline;hp=-c Merge branch 'nd/tree-walk-path-exclusion' Pathspec matching against a tree object were buggy when negative pathspec elements were involved, which has been fixed. * nd/tree-walk-path-exclusion: tree-walk.c: fix overoptimistic inclusion in :(exclude) matching --- 1e4a714e689e14726982941d8e61db06c6c7d58d diff --combined tree-walk.c index 77b37f36fa,108cdc8a7a..79bafbd1a2 --- a/tree-walk.c +++ b/tree-walk.c @@@ -2,7 -2,6 +2,7 @@@ #include "tree-walk.h" #include "unpack-trees.h" #include "dir.h" +#include "object-store.h" #include "tree.h" #include "pathspec.h" @@@ -27,9 -26,8 +27,9 @@@ static int decode_tree_entry(struct tre { const char *path; unsigned int mode, len; + const unsigned hashsz = the_hash_algo->rawsz; - if (size < 23 || buf[size - 21]) { + if (size < hashsz + 3 || buf[size - (hashsz + 1)]) { strbuf_addstr(err, _("too-short tree object")); return -1; } @@@ -1107,7 -1105,7 +1107,7 @@@ enum interesting tree_entry_interesting * 5 | file | 1 | 1 | 0 * 6 | file | 1 | 2 | 0 * 7 | file | 2 | -1 | 2 - * 8 | file | 2 | 0 | 2 + * 8 | file | 2 | 0 | 1 * 9 | file | 2 | 1 | 0 * 10 | file | 2 | 2 | -1 * -----+-------+----------+----------+------- @@@ -1118,7 -1116,7 +1118,7 @@@ * 15 | dir | 1 | 1 | 1 (*) * 16 | dir | 1 | 2 | 0 * 17 | dir | 2 | -1 | 2 - * 18 | dir | 2 | 0 | 2 + * 18 | dir | 2 | 0 | 1 * 19 | dir | 2 | 1 | 1 (*) * 20 | dir | 2 | 2 | -1 * @@@ -1134,7 -1132,12 +1134,12 @@@ negative = do_match(entry, base, base_offset, ps, 1); - /* #3, #4, #7, #8, #13, #14, #17, #18 */ + /* #8, #18 */ + if (positive == all_entries_interesting && + negative == entry_not_interesting) + return entry_interesting; + + /* #3, #4, #7, #13, #14, #17 */ if (negative <= entry_not_interesting) return positive;