]> git.ipfire.org Git - thirdparty/git.git/commitdiff
path: expose `do_git_common_path()` as `repo_common_pathv()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 13 Aug 2024 09:13:23 +0000 (11:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Aug 2024 17:01:00 +0000 (10:01 -0700)
With the same reasoning as the preceding commit, expose the function
`do_git_common_path()` as `repo_common_pathv()`. While at it, reorder
parameters such that they match the order we have in `repo_git_pathv()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
path.c
path.h

diff --git a/path.c b/path.c
index 71f1cb4dfbce0b88ffb6217bbdcab17d19cb775d..069db6ff8f2c501bdfa4166859c4694d2c98190a 100644 (file)
--- a/path.c
+++ b/path.c
@@ -617,16 +617,16 @@ int strbuf_git_path_submodule(struct strbuf *buf, const char *path,
        return err;
 }
 
-static void do_git_common_path(const struct repository *repo,
-                              struct strbuf *buf,
-                              const char *fmt,
-                              va_list args)
+void repo_common_pathv(const struct repository *repo,
+                      struct strbuf *sb,
+                      const char *fmt,
+                      va_list args)
 {
-       strbuf_addstr(buf, repo->commondir);
-       if (buf->len && !is_dir_sep(buf->buf[buf->len - 1]))
-               strbuf_addch(buf, '/');
-       strbuf_vaddf(buf, fmt, args);
-       strbuf_cleanup_path(buf);
+       strbuf_addstr(sb, repo->commondir);
+       if (sb->len && !is_dir_sep(sb->buf[sb->len - 1]))
+               strbuf_addch(sb, '/');
+       strbuf_vaddf(sb, fmt, args);
+       strbuf_cleanup_path(sb);
 }
 
 const char *git_common_path(const char *fmt, ...)
@@ -634,7 +634,7 @@ const char *git_common_path(const char *fmt, ...)
        struct strbuf *pathname = get_pathname();
        va_list args;
        va_start(args, fmt);
-       do_git_common_path(the_repository, pathname, fmt, args);
+       repo_common_pathv(the_repository, pathname, fmt, args);
        va_end(args);
        return pathname->buf;
 }
@@ -645,7 +645,7 @@ void strbuf_git_common_path(struct strbuf *sb,
 {
        va_list args;
        va_start(args, fmt);
-       do_git_common_path(repo, sb, fmt, args);
+       repo_common_pathv(repo, sb, fmt, args);
        va_end(args);
 }
 
diff --git a/path.h b/path.h
index 94e7030f0b4f960bf695b2e34b2fc4aaa3627e57..05aff5f4c3b2ef58361b2a3471e314274aad98fe 100644 (file)
--- a/path.h
+++ b/path.h
@@ -37,6 +37,10 @@ void strbuf_git_common_path(struct strbuf *sb,
                            const struct repository *repo,
                            const char *fmt, ...)
        __attribute__((format (printf, 3, 4)));
+void repo_common_pathv(const struct repository *repo,
+                      struct strbuf *buf,
+                      const char *fmt,
+                      va_list args);
 
 /*
  * Return a statically allocated path into the main repository's
@@ -45,7 +49,6 @@ void strbuf_git_common_path(struct strbuf *sb,
 const char *git_common_path(const char *fmt, ...)
        __attribute__((format (printf, 1, 2)));
 
-
 /*
  * The `git_path` family of functions will construct a path into a repository's
  * git directory.