Commit Diff


commit - 7839bc15b2c146222489bd8d61a1dede43fecbbf
commit + 6e9da951ccdba2e3e9ffe11c8a0ae030930fcd11
blob - 2c7f872154b99b9eada5a12383625b9d054640b6
blob + 4f82cdfa003235ead5cafae41c7c29eb0812d7d0
--- include/got_repository.h
+++ include/got_repository.h
@@ -21,12 +21,12 @@ const struct got_error *got_repo_open(struct got_repos
 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 *);
blob - a2c190401d8f03bc571561ea443bf15c6b10b698
blob + caef76185aa7f03c6fb4b7f60d353dcdfc9c0a19
--- lib/reference.c
+++ lib/reference.c
@@ -153,7 +153,7 @@ get_refs_dir_path(struct got_repository *repo, const c
 	    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);
 }
blob - bd30c00e28ab48d392f7c6a02f4f70e2cf90e5e3
blob + 938d64fe4e37f8aa65ba770d6bc3d3defb2add5d
--- lib/repository.c
+++ 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);