MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / gf_relative_path

Function gf_relative_path

src/mcp/test_impact_git.c:1047–1068  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1045}
1046
1047static bool gf_relative_path(const char *path, size_t n) {
1048 if (!path || !n || n > GF_INPUT_MAX || path[0] == '/' || memchr(path, '\0', n))
1049 return false;
1050#ifdef _WIN32
1051 /* Windows Git normalizes backslashes before lookup. Reject that spelling
1052 * rather than silently selecting a different Git tree path. */
1053 if (memchr(path, '\\', n) || (n >= 2 && path[1] == ':') ||
1054 MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path, (int)n, NULL, 0) == 0)
1055 return false;
1056#endif
1057 size_t begin = 0;
1058 for (size_t i = 0; i <= n; i++) {
1059 if (i != n && path[i] != '/')
1060 continue;
1061 size_t length = i - begin;
1062 if (!length || (length == 1 && path[begin] == '.') ||
1063 (length == 2 && path[begin] == '.' && path[begin + 1] == '.'))
1064 return false;
1065 begin = i + 1;
1066 }
1067 return true;
1068}
1069
1070static const char *gf_revision(const cbm_git_facts_t *facts, cbm_git_revision_t revision) {
1071 switch (revision) {

Callers 2

cbm_git_facts_read_blobFunction · 0.85
gf_names_validFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected