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

Function find_worktree_by_suffix

worktree.c:237–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237static struct worktree *find_worktree_by_suffix(struct worktree **list,
238 const char *suffix)
239{
240 struct worktree *found = NULL;
241 int nr_found = 0, suffixlen;
242
243 suffixlen = strlen(suffix);
244 if (!suffixlen)
245 return NULL;
246
247 for (; *list && nr_found < 2; list++) {
248 const char *path = (*list)->path;
249 int pathlen = strlen(path);
250 int start = pathlen - suffixlen;
251
252 /* suffix must start at directory boundary */
253 if ((!start || (start > 0 && is_dir_sep(path[start - 1]))) &&
254 !fspathcmp(suffix, path + start)) {
255 found = *list;
256 nr_found++;
257 }
258 }
259 return nr_found == 1 ? found : NULL;
260}
261
262struct worktree *find_worktree(struct worktree **list,
263 const char *prefix,

Callers 1

find_worktreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected