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

Function has_file_name

read-cache.c:1055–1082  ·  view source on GitHub ↗

* Do we have another file that has the beginning components being a * proper superset of the name we're trying to add? */

Source from the content-addressed store, hash-verified

1053 * proper superset of the name we're trying to add?
1054 */
1055static int has_file_name(struct index_state *istate,
1056 const struct cache_entry *ce, int pos, int ok_to_replace)
1057{
1058 int retval = 0;
1059 int len = ce_namelen(ce);
1060 int stage = ce_stage(ce);
1061 const char *name = ce->name;
1062
1063 while (pos < istate->cache_nr) {
1064 struct cache_entry *p = istate->cache[pos++];
1065
1066 if (len >= ce_namelen(p))
1067 break;
1068 if (memcmp(name, p->name, len))
1069 break;
1070 if (ce_stage(p) != stage)
1071 continue;
1072 if (p->name[len] != '/')
1073 continue;
1074 if (p->ce_flags & CE_REMOVE)
1075 continue;
1076 retval = -1;
1077 if (!ok_to_replace)
1078 break;
1079 remove_index_entry_at(istate, --pos);
1080 }
1081 return retval;
1082}
1083
1084
1085/*

Callers 1

Calls 1

remove_index_entry_atFunction · 0.85

Tested by

no test coverage detected