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

Function strip_last_component

abspath.c:17–30  ·  view source on GitHub ↗

removes the last path component from 'path' except if 'path' is root */

Source from the content-addressed store, hash-verified

15
16/* removes the last path component from 'path' except if 'path' is root */
17static void strip_last_component(struct strbuf *path)
18{
19 size_t offset = offset_1st_component(path->buf);
20 size_t len = path->len;
21
22 /* Find start of the last component */
23 while (offset < len && !is_dir_sep(path->buf[len - 1]))
24 len--;
25 /* Skip sequences of multiple path-separators */
26 while (offset < len && is_dir_sep(path->buf[len - 1]))
27 len--;
28
29 strbuf_setlen(path, len);
30}
31
32/* get (and remove) the next component in 'remaining' and place it in 'next' */
33static void get_next_component(struct strbuf *next, struct strbuf *remaining)

Callers 1

strbuf_realpath_1Function · 0.85

Calls 1

strbuf_setlenFunction · 0.85

Tested by

no test coverage detected