From 72417640769c91408d15cdbab3160bc494f49c7f Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Mon, 12 Dec 2016 10:16:54 -0800 Subject: real_path: create real_pathdup Create real_pathdup which returns a caller owned string of the resolved realpath based on the provide path. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- abspath.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'abspath.c') diff --git a/abspath.c b/abspath.c index 8c6c76b05e..79ee310867 100644 --- a/abspath.c +++ b/abspath.c @@ -205,6 +205,19 @@ const char *real_path_if_valid(const char *path) return strbuf_realpath(&realpath, path, 0); } +char *real_pathdup(const char *path) +{ + struct strbuf realpath = STRBUF_INIT; + char *retval = NULL; + + if (strbuf_realpath(&realpath, path, 0)) + retval = strbuf_detach(&realpath, NULL); + + strbuf_release(&realpath); + + return retval; +} + /* * Use this to get an absolute path from a relative one. If you want * to resolve links, you should use real_path. -- cgit v1.2.3