make got_repo_get_path_git_dir() return const char *
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
diff --git a/include/got_repository.h b/include/got_repository.h
index 2c7f872..4f82cdf 100644
--- a/include/got_repository.h
+++ b/include/got_repository.h
@@ -21,12 +21,12 @@ const struct got_error *got_repo_open(struct got_repository**, const char *);
const struct got_error *got_repo_close(struct got_repository*);
const char *got_repo_get_path(struct got_repository *);
+const char *got_repo_get_path_git_dir(struct got_repository *);
/*
* Obtain paths to various directories within a repository.
* The caller must dispose of a path with free(3).
*/
-char *got_repo_get_path_git_dir(struct got_repository *);
char *got_repo_get_path_objects(struct got_repository *);
char *got_repo_get_path_objects_pack(struct got_repository *);
char *got_repo_get_path_refs(struct got_repository *);
diff --git a/lib/reference.c b/lib/reference.c
index a2c1904..caef761 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -153,7 +153,7 @@ get_refs_dir_path(struct got_repository *repo, const char *refname)
strcmp(refname, GOT_REF_MERGE_HEAD) == 0 ||
strcmp(refname, GOT_REF_FETCH_HEAD) == 0 ||
strncmp(refname, "refs/", 5) == 0)
- return got_repo_get_path_git_dir(repo);
+ return strdup(got_repo_get_path_git_dir(repo));
return got_repo_get_path_refs(repo);
}
diff --git a/lib/repository.c b/lib/repository.c
index bd30c00..938d64f 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -72,10 +72,10 @@ got_repo_get_path(struct got_repository *repo)
return repo->path;
}
-char *
+const char *
got_repo_get_path_git_dir(struct got_repository *repo)
{
- return strdup(repo->path_git_dir);
+ return repo->path_git_dir;
}
int
@@ -123,7 +123,7 @@ get_path_head(struct got_repository *repo)
static int
is_git_repo(struct got_repository *repo)
{
- char *path_git = got_repo_get_path_git_dir(repo);
+ const char *path_git = got_repo_get_path_git_dir(repo);
char *path_objects = got_repo_get_path_objects(repo);
char *path_refs = got_repo_get_path_refs(repo);
char *path_head = get_path_head(repo);
@@ -158,7 +158,6 @@ is_git_repo(struct got_repository *repo)
ret = 1;
done:
- free(path_git);
free(path_objects);
free(path_refs);
free(path_head);