MCPcopy Create free account
hub / github.com/git/git / path_is_beyond_symlink_1

Function path_is_beyond_symlink_1

apply.c:3989–4021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3987}
3988
3989static 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
4023static int path_is_beyond_symlink(struct apply_state *state, const char *name_)
4024{

Callers 1

path_is_beyond_symlinkFunction · 0.85

Calls 2

strset_containsFunction · 0.85
index_file_existsFunction · 0.85

Tested by

no test coverage detected