commit - 4df642d96698f559d3c086843ecd7c411f9963aa
commit + 92af54690507460b948ced62a12b3bc7e4b2a244
blob - 5adeb94e5b3caec17009e5f1a22d520949aca1c0
blob + 021ae95760630951fea30363f50a41c41923eb7a
--- lib/path.c
+++ lib/path.c
return resolved;
}
-
-int
-got_path_is_normalized(const char *path)
-{
- char *normpath;
- int ret;
-
- normpath = got_path_normalize(path);
- ret = (strcmp(normpath, path) == 0);
- free(normpath);
-
- return ret;
-}
blob - f96d8386ea1f6ce81118440eab08d45a8edae8dd
blob + afc8ee3bb78487c9cbb26074bb67c7d30b5a2694
--- lib/repository.c
+++ lib/repository.c
}
const struct got_error *
-got_repo_open(struct got_repository **ret, const char *abspath)
+got_repo_open(struct got_repository **ret, const char *path)
{
- struct got_repository *repo;
+ struct got_repository *repo = NULL;
+ const struct got_error *err = NULL;
+ char *abspath = got_path_get_absolute(path);
- if (!got_path_is_absolute(abspath))
- return got_error(GOT_ERR_NOT_ABSPATH);
+ if (abspath == NULL)
+ return got_error(GOT_ERR_BAD_PATH);
repo = calloc(1, sizeof(*repo));
- if (repo == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ if (repo == NULL) {
+ err = got_error(GOT_ERR_NO_MEM);
+ goto done;
+ }
repo->path = got_path_normalize(abspath);
- if (repo->path == NULL)
- return got_error(GOT_ERR_BAD_PATH);
+ if (repo->path == NULL) {
+ err = got_error(GOT_ERR_BAD_PATH);
+ goto done;
+ }
- if (!is_git_repo(repo))
- return got_error(GOT_ERR_NOT_GIT_REPO);
+ if (!is_git_repo(repo)) {
+ err = got_error(GOT_ERR_NOT_GIT_REPO);
+ goto done;
+ }
*ret = repo;
- return NULL;
+done:
+ if (err)
+ free(repo);
+ free(abspath);
+ return err;
}
void
blob - 4ddf99cac3ba850c83d0b0537e4d63326194cf65
blob + f70ab8cdc937290abf9b2d0afd92733f30acc517
--- regress/repository/repository_test.c
+++ regress/repository/repository_test.c
#include <sha1.h>
#include "got_error.h"
-#include "got_path.h"
#include "got_refs.h"
#include "got_repository.h"
const char *abspath;
int ret;
- abspath = got_path_normalize(repo_path);
- err = got_repo_open(&repo, abspath);
+ err = got_repo_open(&repo, repo_path);
ret = (err == NULL && repo != NULL);
got_repo_close(repo);
return ret;
const struct got_error *err;
struct got_repository *repo;
struct got_reference *head_ref;
- const char *abspath;
int ret;
- abspath = got_path_normalize(repo_path);
- err = got_repo_open(&repo, abspath);
+ err = got_repo_open(&repo, repo_path);
if (err != NULL || repo == NULL)
return 0;
err = got_repo_get_reference(&head_ref, repo, GOT_REF_HEAD);