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

Function trim_last_path_component

lockfile.c:20–36  ·  view source on GitHub ↗

* path = absolute or relative path name * * Remove the last path name element from path (leaving the preceding * "/", if any). If path is empty or the root directory ("/"), set * path to the empty string. */

Source from the content-addressed store, hash-verified

18 * path to the empty string.
19 */
20static void trim_last_path_component(struct strbuf *path)
21{
22 int i = path->len;
23
24 /* back up past trailing slashes, if any */
25 while (i && is_dir_sep(path->buf[i - 1]))
26 i--;
27
28 /*
29 * then go backwards until a slash, or the beginning of the
30 * string
31 */
32 while (i && !is_dir_sep(path->buf[i - 1]))
33 i--;
34
35 strbuf_setlen(path, i);
36}
37
38
39/* We allow "recursive" symbolic links. Only within reason, though */

Callers 1

resolve_symlinkFunction · 0.85

Calls 1

strbuf_setlenFunction · 0.85

Tested by

no test coverage detected