diff options
| author | Russell Belfer <arrbee@arrbee.com> | 2012-01-09 15:46:06 -0800 |
|---|---|---|
| committer | Russell Belfer <arrbee@arrbee.com> | 2012-01-09 15:46:06 -0800 |
| commit | 7e443f696068cd8c84a759e532c2845348e5a6ad (patch) | |
| tree | bbdae136c02d4ac674c1adbbb463080fc0df9aba /src/path.c | |
| parent | 1d175074969ea47fdaca95cf9912fa2e74aa156e (diff) | |
| download | libgit2-7e443f696068cd8c84a759e532c2845348e5a6ad.tar.gz | |
Restore portability to git_path_prettify.
It turns out that passing NULL for the second parameter of realpath(3)
is not as portable as one might like. Notably, Mac OS 10.5 and earlier
does not support it. So this moves us back to a large buffer to get
the realpath info.
Diffstat (limited to 'src/path.c')
| -rw-r--r-- | src/path.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/path.c b/src/path.c index 8c1bd41eb..f9663b7e5 100644 --- a/src/path.c +++ b/src/path.c @@ -181,8 +181,8 @@ int git_path_root(const char *path) int git_path_prettify(git_buf *path_out, const char *path, const char *base) { - char *result = NULL; - int error = GIT_SUCCESS; + int error = GIT_SUCCESS; + char buf[GIT_PATH_MAX]; git_buf_clear(path_out); @@ -193,16 +193,10 @@ int git_path_prettify(git_buf *path_out, const char *path, const char *base) path = path_out->ptr; } - /* allow realpath to allocate the buffer */ - if (path != NULL) - result = p_realpath(path, NULL); - - if (result) { - error = git_buf_sets(path_out, result); - git__free(result); - } else { + if (path == NULL || p_realpath(path, buf) == NULL) error = GIT_EOSERR; - } + else + error = git_buf_sets(path_out, buf); return error; } |
