* Note that traverse_by_cache_tree() duplicates some logic in this function * without actually calling it. If you change the logic here you may need to * check and change there as well. */
| 1161 | * check and change there as well. |
| 1162 | */ |
| 1163 | static int unpack_single_entry(int n, unsigned long mask, |
| 1164 | unsigned long dirmask, |
| 1165 | struct cache_entry **src, |
| 1166 | const struct name_entry *names, |
| 1167 | const struct traverse_info *info, |
| 1168 | int *is_new_sparse_dir) |
| 1169 | { |
| 1170 | int i; |
| 1171 | struct unpack_trees_options *o = info->data; |
| 1172 | unsigned long conflicts = info->df_conflicts | dirmask; |
| 1173 | const struct name_entry *p = names; |
| 1174 | |
| 1175 | *is_new_sparse_dir = 0; |
| 1176 | if (mask == dirmask && !src[0]) { |
| 1177 | /* |
| 1178 | * If we're not in a sparse index, we can't unpack a directory |
| 1179 | * without recursing into it, so we return. |
| 1180 | */ |
| 1181 | if (!o->src_index->sparse_index) |
| 1182 | return 0; |
| 1183 | |
| 1184 | /* Find first entry with a real name (we could use "mask" too) */ |
| 1185 | while (!p->mode) |
| 1186 | p++; |
| 1187 | |
| 1188 | /* |
| 1189 | * If the directory is completely missing from the index but |
| 1190 | * would otherwise be a sparse directory, we should unpack it. |
| 1191 | * If not, we'll return and continue recursively traversing the |
| 1192 | * tree. |
| 1193 | */ |
| 1194 | *is_new_sparse_dir = entry_is_new_sparse_dir(info, p); |
| 1195 | if (!*is_new_sparse_dir) |
| 1196 | return 0; |
| 1197 | } |
| 1198 | |
| 1199 | /* |
| 1200 | * When we are unpacking a sparse directory, then this isn't necessarily |
| 1201 | * a directory-file conflict. |
| 1202 | */ |
| 1203 | if (mask == dirmask && |
| 1204 | (*is_new_sparse_dir || (src[0] && S_ISSPARSEDIR(src[0]->ce_mode)))) |
| 1205 | conflicts = 0; |
| 1206 | |
| 1207 | /* |
| 1208 | * Ok, we've filled in up to any potential index entry in src[0], |
| 1209 | * now do the rest. |
| 1210 | */ |
| 1211 | for (i = 0; i < n; i++) { |
| 1212 | int stage; |
| 1213 | unsigned int bit = 1ul << i; |
| 1214 | if (conflicts & bit) { |
| 1215 | src[i + o->merge] = o->df_conflict_entry; |
| 1216 | continue; |
| 1217 | } |
| 1218 | if (!(mask & bit)) |
| 1219 | continue; |
| 1220 | if (!o->merge) |
no test coverage detected