From 88dd321cfedc6ee190dfafe4670a83ea33cdf4a3 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 7 Feb 2025 12:03:37 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- path.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'path.c') diff --git a/path.c b/path.c index 2d07ba723d..a42f72800d 100644 --- a/path.c +++ b/path.c @@ -30,7 +30,7 @@ static int get_st_mode_bits(const char *path, int *mode) return 0; } -struct strbuf *get_pathname(void) +static struct strbuf *get_pathname(void) { static struct strbuf pathname_array[4] = { STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT @@ -417,9 +417,9 @@ static void strbuf_worktree_gitdir(struct strbuf *buf, repo_common_path_append(repo, buf, "worktrees/%s", wt->id); } -void repo_git_pathv(const struct repository *repo, - const struct worktree *wt, struct strbuf *buf, - const char *fmt, va_list args) +static void repo_git_pathv(const struct repository *repo, + const struct worktree *wt, struct strbuf *buf, + const char *fmt, va_list args) { int gitdir_len; strbuf_worktree_gitdir(buf, repo, wt); -- cgit 1.2.3-korg