aboutsummaryrefslogtreecommitdiffstats
path: root/path.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-02-07 12:03:27 +0100
committerJunio C Hamano <gitster@pobox.com>2025-02-07 09:59:21 -0800
commitbdfc07bfdf3f4f4ef94580c0cb46eef5977bb810 (patch)
treeec25e305b583e03f6fbacf8f5594d7188d86fdb8 /path.c
parentpath: refactor `repo_common_path()` family of functions (diff)
downloadgit-bdfc07bfdf3f4f4ef94580c0cb46eef5977bb810.tar.gz
git-bdfc07bfdf3f4f4ef94580c0cb46eef5977bb810.zip
path: refactor `repo_git_path()` family of functions
As explained in an earlier commit, we're refactoring path-related functions to provide a consistent interface for computing paths into the commondir, gitdir and worktree. Refactor the "gitdir" family of functions accordingly. Note that the `repo_git_pathv()` function is converted into an internal implementation detail. It is only used to implement `the_repository` compatibility shims and will eventually be removed from the public interface. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'path.c')
-rw-r--r--path.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/path.c b/path.c
index 273b649e00..779aa94b56 100644
--- a/path.c
+++ b/path.c
@@ -443,14 +443,27 @@ char *repo_git_path(const struct repository *repo,
return strbuf_detach(&path, NULL);
}
-void strbuf_repo_git_path(struct strbuf *sb,
- const struct repository *repo,
- const char *fmt, ...)
+const char *repo_git_path_append(const struct repository *repo,
+ struct strbuf *sb,
+ const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
repo_git_pathv(repo, NULL, sb, fmt, args);
va_end(args);
+ return sb->buf;
+}
+
+const char *repo_git_path_replace(const struct repository *repo,
+ struct strbuf *sb,
+ const char *fmt, ...)
+{
+ va_list args;
+ strbuf_reset(sb);
+ va_start(args, fmt);
+ repo_git_pathv(repo, NULL, sb, fmt, args);
+ va_end(args);
+ return sb->buf;
}
char *mkpathdup(const char *fmt, ...)