aboutsummaryrefslogtreecommitdiff
path: root/abspath.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@elego.de>2011-03-17 12:26:46 +0100
committerJunio C Hamano <gitster@pobox.com>2011-03-17 16:08:30 -0700
commite2a57aac8a8a2b786739a5a93ea9dcfd2f0fd0e2 (patch)
treeb17a832e94e5b0e6eeff36616a46205f4eb84571 /abspath.c
parenta3ca9b0fbe21d7a2525877fe0c008b61c56f7104 (diff)
downloadgit-e2a57aac8a8a2b786739a5a93ea9dcfd2f0fd0e2.tar.gz
git-e2a57aac8a8a2b786739a5a93ea9dcfd2f0fd0e2.tar.xz
Name make_*_path functions more accurately
Rename the make_*_path functions so it's clearer what they do, in particlar make clear what the differnce between make_absolute_path and make_nonrelative_path is by renaming them real_path and absolute_path respectively. make_relative_path has an understandable name and is renamed to relative_path to maintain the name convention. The function calls have been replaced 1-to-1 in their usage. Signed-off-by: Carlos Martín Nieto <cmn@elego.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'abspath.c')
-rw-r--r--abspath.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/abspath.c b/abspath.c
index ff140689e..3005aedde 100644
--- a/abspath.c
+++ b/abspath.c
@@ -14,7 +14,14 @@ int is_directory(const char *path)
/* We allow "recursive" symbolic links. Only within reason, though. */
#define MAXDEPTH 5
-const char *make_absolute_path(const char *path)
+/*
+ * Use this to get the real path, i.e. resolve links. If you want an
+ * absolute path but don't mind links, use absolute_path.
+ *
+ * If path is our buffer, then return path, as it's already what the
+ * user wants.
+ */
+const char *real_path(const char *path)
{
static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
char cwd[1024] = "";
@@ -104,7 +111,14 @@ static const char *get_pwd_cwd(void)
return cwd;
}
-const char *make_nonrelative_path(const char *path)
+/*
+ * Use this to get an absolute path from a relative one. If you want
+ * to resolve links, you should use real_path.
+ *
+ * If the path is already absolute, then return path. As the user is
+ * never meant to free the return value, we're safe.
+ */
+const char *absolute_path(const char *path)
{
static char buf[PATH_MAX + 1];