in got_repo_open(), let realpath(3) take care of relative paths
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/lib/repository.c b/lib/repository.c
index d5c352f..e604a69 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -589,18 +589,11 @@ got_repo_open(struct got_repository **repop, const char *path,
{
struct got_repository *repo = NULL;
const struct got_error *err = NULL;
- char *abspath, *repo_path = NULL;
+ char *repo_path = NULL;
size_t i;
*repop = NULL;
- if (got_path_is_absolute(path))
- abspath = strdup(path);
- else
- abspath = got_path_get_absolute(path);
- if (abspath == NULL)
- return got_error_path(path, GOT_ERR_BAD_PATH);
-
repo = calloc(1, sizeof(*repo));
if (repo == NULL) {
err = got_error_from_errno("calloc");
@@ -630,9 +623,9 @@ got_repo_open(struct got_repository **repop, const char *path,
if (err)
goto done;
- repo_path = realpath(abspath, NULL);
+ repo_path = realpath(path, NULL);
if (repo_path == NULL) {
- err = got_error_from_errno2("realpath", abspath);
+ err = got_error_from_errno2("realpath", path);
goto done;
}
@@ -683,7 +676,6 @@ done:
got_repo_close(repo);
else
*repop = repo;
- free(abspath);
free(repo_path);
return err;
}