sequencer: refactor transform_todos() to work on a todo_list
[gitweb.git] / tree-walk.c
index 8f5090862b5193db135f18854974b21e75eb8ae4..79bafbd1a23c4a9e20ec623c084778904c534be7 100644 (file)
@@ -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"
 
@@ -26,8 +27,9 @@ static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned l
 {
        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;
        }
@@ -1105,7 +1107,7 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
         *   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
         * -----+-------+----------+----------+-------
@@ -1116,7 +1118,7 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
         *  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
         *
@@ -1132,7 +1134,12 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
 
        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;