* Compare two tree entries, taking into account only path/S_ISDIR(mode), * but not their sha1's. * * NOTE files and directories *always* compare differently, even when having * the same name - thanks to base_name_compare(). * * NOTE empty (=invalid) descriptor(s) take part in comparison as +infty, * so that they sort *after* valid tree entries. * * Due to this convention, i
| 137 | * non-empty descriptors will be processed first. |
| 138 | */ |
| 139 | static int tree_entry_pathcmp(struct tree_desc *t1, struct tree_desc *t2) |
| 140 | { |
| 141 | struct name_entry *e1, *e2; |
| 142 | int cmp; |
| 143 | |
| 144 | /* empty descriptors sort after valid tree entries */ |
| 145 | if (!t1->size) |
| 146 | return t2->size ? 1 : 0; |
| 147 | else if (!t2->size) |
| 148 | return -1; |
| 149 | |
| 150 | e1 = &t1->entry; |
| 151 | e2 = &t2->entry; |
| 152 | cmp = base_name_compare(e1->path, tree_entry_len(e1), e1->mode, |
| 153 | e2->path, tree_entry_len(e2), e2->mode); |
| 154 | return cmp; |
| 155 | } |
| 156 | |
| 157 | |
| 158 | /* |
no test coverage detected