| 1268 | } |
| 1269 | |
| 1270 | static const char *builtin_object_mode_attr(struct index_state *istate, const char *path) |
| 1271 | { |
| 1272 | unsigned int mode; |
| 1273 | |
| 1274 | if (direction == GIT_ATTR_CHECKIN) { |
| 1275 | struct object_id oid; |
| 1276 | struct stat st; |
| 1277 | if (lstat(path, &st)) |
| 1278 | die_errno(_("unable to stat '%s'"), path); |
| 1279 | mode = canon_mode(st.st_mode); |
| 1280 | if (S_ISDIR(mode)) { |
| 1281 | /* |
| 1282 | *`path` is either a directory or it is a submodule, |
| 1283 | * in which case it is already indexed as submodule |
| 1284 | * or it does not exist in the index yet and we need to |
| 1285 | * check if we can resolve to a ref. |
| 1286 | */ |
| 1287 | int pos = index_name_pos(istate, path, strlen(path)); |
| 1288 | if (pos >= 0) { |
| 1289 | if (S_ISGITLINK(istate->cache[pos]->ce_mode)) |
| 1290 | mode = istate->cache[pos]->ce_mode; |
| 1291 | } else if (repo_resolve_gitlink_ref(the_repository, path, |
| 1292 | "HEAD", &oid) == 0) { |
| 1293 | mode = S_IFGITLINK; |
| 1294 | } |
| 1295 | } |
| 1296 | } else { |
| 1297 | /* |
| 1298 | * For GIT_ATTR_CHECKOUT and GIT_ATTR_INDEX we only check |
| 1299 | * for mode in the index. |
| 1300 | */ |
| 1301 | int pos = index_name_pos(istate, path, strlen(path)); |
| 1302 | if (pos >= 0) |
| 1303 | mode = istate->cache[pos]->ce_mode; |
| 1304 | else |
| 1305 | return ATTR__UNSET; |
| 1306 | } |
| 1307 | |
| 1308 | return interned_mode_string(mode); |
| 1309 | } |
| 1310 | |
| 1311 | |
| 1312 | static const char *compute_builtin_attr(struct index_state *istate, |
no test coverage detected