* 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. */
| 18 | * path to the empty string. |
| 19 | */ |
| 20 | static 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 */ |
no test coverage detected