| 3987 | } |
| 3988 | |
| 3989 | static int path_is_beyond_symlink_1(struct apply_state *state, struct strbuf *name) |
| 3990 | { |
| 3991 | do { |
| 3992 | while (--name->len && name->buf[name->len] != '/') |
| 3993 | ; /* scan backwards */ |
| 3994 | if (!name->len) |
| 3995 | break; |
| 3996 | name->buf[name->len] = '\0'; |
| 3997 | if (strset_contains(&state->kept_symlinks, name->buf)) |
| 3998 | return 1; |
| 3999 | if (strset_contains(&state->removed_symlinks, name->buf)) |
| 4000 | /* |
| 4001 | * This cannot be "return 0", because we may |
| 4002 | * see a new one created at a higher level. |
| 4003 | */ |
| 4004 | continue; |
| 4005 | |
| 4006 | /* otherwise, check the preimage */ |
| 4007 | if (state->check_index) { |
| 4008 | struct cache_entry *ce; |
| 4009 | |
| 4010 | ce = index_file_exists(state->repo->index, name->buf, |
| 4011 | name->len, ignore_case); |
| 4012 | if (ce && S_ISLNK(ce->ce_mode)) |
| 4013 | return 1; |
| 4014 | } else { |
| 4015 | struct stat st; |
| 4016 | if (!lstat(name->buf, &st) && S_ISLNK(st.st_mode)) |
| 4017 | return 1; |
| 4018 | } |
| 4019 | } while (1); |
| 4020 | return 0; |
| 4021 | } |
| 4022 | |
| 4023 | static int path_is_beyond_symlink(struct apply_state *state, const char *name_) |
| 4024 | { |
no test coverage detected