| 379 | } |
| 380 | |
| 381 | static int process_path(const char *path, struct stat *st, int stat_errno) |
| 382 | { |
| 383 | int pos, len; |
| 384 | const struct cache_entry *ce; |
| 385 | |
| 386 | len = strlen(path); |
| 387 | if (has_symlink_leading_path(path, len)) |
| 388 | return error("'%s' is beyond a symbolic link", path); |
| 389 | |
| 390 | pos = index_name_pos(the_repository->index, path, len); |
| 391 | ce = pos < 0 ? NULL : the_repository->index->cache[pos]; |
| 392 | if (ce && ce_skip_worktree(ce)) { |
| 393 | /* |
| 394 | * working directory version is assumed "good" |
| 395 | * so updating it does not make sense. |
| 396 | * On the other hand, removing it from index should work |
| 397 | */ |
| 398 | if (!ignore_skip_worktree_entries && allow_remove && |
| 399 | remove_file_from_index(the_repository->index, path)) |
| 400 | return error("%s: cannot remove from the index", path); |
| 401 | return 0; |
| 402 | } |
| 403 | |
| 404 | /* |
| 405 | * First things first: get the stat information, to decide |
| 406 | * what to do about the pathname! |
| 407 | */ |
| 408 | if (stat_errno) |
| 409 | return process_lstat_error(path, stat_errno); |
| 410 | |
| 411 | if (S_ISDIR(st->st_mode)) |
| 412 | return process_directory(path, len, st); |
| 413 | |
| 414 | return add_one_path(ce, path, len, st); |
| 415 | } |
| 416 | |
| 417 | static int add_cacheinfo(unsigned int mode, const struct object_id *oid, |
| 418 | const char *path, int stage) |
no test coverage detected