summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2020-12-13 00:25:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-12-13 07:35:47 (GMT)
commitbe6e0daee700b2ee28846b54ddfefe08cd4ec506 (patch)
tree8a1e2f49bf04b541f314fe2aec632de921475d53 /cache.h
parent3cf59784d42c4152a0b3de7bb7a75d0071e5f878 (diff)
downloadgit-be6e0daee700b2ee28846b54ddfefe08cd4ec506.zip
git-be6e0daee700b2ee28846b54ddfefe08cd4ec506.tar.gz
git-be6e0daee700b2ee28846b54ddfefe08cd4ec506.tar.bz2
abspath: add a function to resolve paths with missing components
Currently, we have a function to resolve paths, strbuf_realpath. This function canonicalizes paths like realpath(3), but permits a trailing component to be absent from the file system. In other words, this is the behavior of the GNU realpath(1) without any arguments. In the future, we'll need this same behavior, except that we want to allow for any number of missing trailing components, which is the behavior of GNU realpath(1) with the -m option. This is useful because we'll want to canonicalize a path that may point to a not yet present path under the .git directory. For example, a user may want to know where an arbitrary ref would be stored if it existed in the file system. Let's refactor strbuf_realpath to move most of the code to an internal function and then pass it two flags to control its behavior. We'll add a strbuf_realpath_forgiving function that has our new behavior, and leave strbuf_realpath with the older, stricter behavior. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index 8d279bc..487ebab 100644
--- a/cache.h
+++ b/cache.h
@@ -1325,6 +1325,8 @@ static inline int is_absolute_path(const char *path)
int is_directory(const char *);
char *strbuf_realpath(struct strbuf *resolved, const char *path,
int die_on_error);
+char *strbuf_realpath_forgiving(struct strbuf *resolved, const char *path,
+ int die_on_error);
char *real_pathdup(const char *path, int die_on_error);
const char *absolute_path(const char *path);
char *absolute_pathdup(const char *path);