diff options
Diffstat (limited to 'path.c')
-rw-r--r-- | path.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -15,7 +15,7 @@ #include "submodule-config.h" #include "path.h" #include "packfile.h" -#include "object-store.h" +#include "object-store-ll.h" #include "lockfile.h" #include "exec-cmd.h" #include "wrapper.h" @@ -1213,6 +1213,26 @@ int normalize_path_copy(char *dst, const char *src) return normalize_path_copy_len(dst, src, NULL); } +int strbuf_normalize_path(struct strbuf *src) +{ + struct strbuf dst = STRBUF_INIT; + + strbuf_grow(&dst, src->len); + if (normalize_path_copy(dst.buf, src->buf) < 0) { + strbuf_release(&dst); + return -1; + } + + /* + * normalize_path does not tell us the new length, so we have to + * compute it by looking for the new NUL it placed + */ + strbuf_setlen(&dst, strlen(dst.buf)); + strbuf_swap(src, &dst); + strbuf_release(&dst); + return 0; +} + /* * path = Canonical absolute path * prefixes = string_list containing normalized, absolute paths without |