path: drop git_path()
in favor of repo_git_path()
Remove `git_path()` in favor of the `repo_git_path()` family of functions, which makes the implicit dependency on `the_repository` go away. Note that `git_path()` returned a string allocated via `get_pathname()`, which uses a rotating set of statically allocated buffers. Consequently, callers didn't have to free the returned string. The same isn't true for `repo_common_path()`, so we also have to add logic to free the returned strings. This refactoring also allows us to remove `repo_common_pathv()` as well as `get_pathname()` from the public interface. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
8ee018d863
commit
88dd321cfe
@ -163,7 +163,9 @@ static int delete_git_dir(const char *id)
|
||||
|
||||
static void delete_worktrees_dir_if_empty(void)
|
||||
{
|
||||
rmdir(git_path("worktrees")); /* ignore failed removal */
|
||||
char *path = repo_git_path(the_repository, "worktrees");
|
||||
rmdir(path); /* ignore failed removal */
|
||||
free(path);
|
||||
}
|
||||
|
||||
static void prune_worktree(const char *id, const char *reason)
|
||||
@ -212,8 +214,13 @@ static void prune_worktrees(void)
|
||||
struct strbuf reason = STRBUF_INIT;
|
||||
struct strbuf main_path = STRBUF_INIT;
|
||||
struct string_list kept = STRING_LIST_INIT_DUP;
|
||||
DIR *dir = opendir(git_path("worktrees"));
|
||||
char *path;
|
||||
DIR *dir;
|
||||
struct dirent *d;
|
||||
|
||||
path = repo_git_path(the_repository, "worktrees");
|
||||
dir = opendir(path);
|
||||
free(path);
|
||||
if (!dir)
|
||||
return;
|
||||
while ((d = readdir_skip_dot_and_dotdot(dir)) != NULL) {
|
||||
|
Reference in New Issue
Block a user