summaryrefslogtreecommitdiff
path: root/abspath.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-01-26 17:47:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-01-26 22:51:06 (GMT)
commitb1edb40f255a900154a9e7d34dcb9e0219427bd9 (patch)
treec2a0fc97658e64122f11eb12e9d2bc740457e27b /abspath.c
parentc3808ca6982b0ad7ee9b87eca9b50b9a24ec08b0 (diff)
downloadgit-b1edb40f255a900154a9e7d34dcb9e0219427bd9.zip
git-b1edb40f255a900154a9e7d34dcb9e0219427bd9.tar.gz
git-b1edb40f255a900154a9e7d34dcb9e0219427bd9.tar.bz2
abspath: add absolute_pathdup()
Add a function that returns a buffer containing the absolute path of its argument and a semantic patch for its intended use. It avoids an extra string copy to a static buffer. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'abspath.c')
-rw-r--r--abspath.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/abspath.c b/abspath.c
index 2825de8..af82abd 100644
--- a/abspath.c
+++ b/abspath.c
@@ -152,6 +152,13 @@ const char *absolute_path(const char *path)
return sb.buf;
}
+char *absolute_pathdup(const char *path)
+{
+ struct strbuf sb = STRBUF_INIT;
+ strbuf_add_absolute_path(&sb, path);
+ return strbuf_detach(&sb, NULL);
+}
+
/*
* Unlike prefix_path, this should be used if the named file does
* not have to interact with index entry; i.e. name of a random file