Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-07-06 21:54:46 +0300
committerJunio C Hamano <gitster@pobox.com>2023-07-06 21:54:46 +0300
commit67e7305e64fea8d15879e9dc3831fc8e31cfe619 (patch)
treed8ed9ee0a2b54f3df4619af5757d938bb5247986 /path.c
parentda269af9207e38e820daad8aa993caa7d2fad76c (diff)
parent787cb8a48ae24ff07fa7c763909bb204bfdc84a7 (diff)
Merge branch 'cw/strbuf-cleanup'
Move functions that are not about pure string manipulation out of strbuf.[ch] * cw/strbuf-cleanup: strbuf: remove global variable path: move related function to path object-name: move related functions to object-name credential-store: move related functions to credential-store file abspath: move related functions to abspath strbuf: clarify dependency strbuf: clarify API boundary
Diffstat (limited to 'path.c')
-rw-r--r--path.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/path.c b/path.c
index c3b6618c77..044a50bad0 100644
--- a/path.c
+++ b/path.c
@@ -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