path: expose `do_git_path()` as `repo_git_pathv()`

We're about to move functions of the "path" subsytem that do not use a `struct repository` into "path.h" as static inlined functions. This will require us to call `do_git_path()`, which is internal to "path.c". Expose the function as `repo_git_pathv()` to prepare for the change. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Aug 13, 2024 at 11:13 UTC b6c6bfef31e1ffe3804e5a1ba5bfe9e7879eda92
2 files changed +18 -10
path.c
+10 -10
@@ -417,9 +417,9 @@ static void strbuf_worktree_gitdir(struct strbuf *buf,
417 strbuf_git_common_path(buf, repo, "worktrees/%s", wt->id);
418 }
419
420 -static void do_git_path(const struct repository *repo,
421 - const struct worktree *wt, struct strbuf *buf,
422 - const char *fmt, va_list args)
420 +void repo_git_pathv(const struct repository *repo,
421 + const struct worktree *wt, struct strbuf *buf,
422 + const char *fmt, va_list args)
423 {
424 int gitdir_len;
425 strbuf_worktree_gitdir(buf, repo, wt);
@@ -438,7 +438,7 @@ char *repo_git_path(const struct repository *repo,
438 struct strbuf path = STRBUF_INIT;
439 va_list args;
440 va_start(args, fmt);
441 - do_git_path(repo, NULL, &path, fmt, args);
441 + repo_git_pathv(repo, NULL, &path, fmt, args);
442 va_end(args);
443 return strbuf_detach(&path, NULL);
444 }
@@ -449,7 +449,7 @@ void strbuf_repo_git_path(struct strbuf *sb,
449 {
450 va_list args;
451 va_start(args, fmt);
452 - do_git_path(repo, NULL, sb, fmt, args);
452 + repo_git_pathv(repo, NULL, sb, fmt, args);
453 va_end(args);
454 }
455
@@ -458,7 +458,7 @@ char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
458 va_list args;
459 strbuf_reset(buf);
460 va_start(args, fmt);
461 - do_git_path(the_repository, NULL, buf, fmt, args);
461 + repo_git_pathv(the_repository, NULL, buf, fmt, args);
462 va_end(args);
463 return buf->buf;
464 }
@@ -467,7 +467,7 @@ void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
467 {
468 va_list args;
469 va_start(args, fmt);
470 - do_git_path(the_repository, NULL, sb, fmt, args);
470 + repo_git_pathv(the_repository, NULL, sb, fmt, args);
471 va_end(args);
472 }
473
@@ -476,7 +476,7 @@ const char *git_path(const char *fmt, ...)
476 struct strbuf *pathname = get_pathname();
477 va_list args;
478 va_start(args, fmt);
479 - do_git_path(the_repository, NULL, pathname, fmt, args);
479 + repo_git_pathv(the_repository, NULL, pathname, fmt, args);
480 va_end(args);
481 return pathname->buf;
482 }
@@ -486,7 +486,7 @@ char *git_pathdup(const char *fmt, ...)
486 struct strbuf path = STRBUF_INIT;
487 va_list args;
488 va_start(args, fmt);
489 - do_git_path(the_repository, NULL, &path, fmt, args);
489 + repo_git_pathv(the_repository, NULL, &path, fmt, args);
490 va_end(args);
491 return strbuf_detach(&path, NULL);
492 }
@@ -517,7 +517,7 @@ const char *worktree_git_path(const struct worktree *wt, const char *fmt, ...)
517 struct strbuf *pathname = get_pathname();
518 va_list args;
519 va_start(args, fmt);
520 - do_git_path(the_repository, wt, pathname, fmt, args);
520 + repo_git_pathv(the_repository, wt, pathname, fmt, args);
521 va_end(args);
522 return pathname->buf;
523 }
path.h
+8
@@ -66,6 +66,14 @@ char *repo_git_path(const struct repository *repo,
66 const char *fmt, ...)
67 __attribute__((format (printf, 2, 3)));
68
69 +/*
70 + * Print a path into the git directory of repository `repo` into the provided
71 + * buffer.
72 + */
73 +void repo_git_pathv(const struct repository *repo,
74 + const struct worktree *wt, struct strbuf *buf,
75 + const char *fmt, va_list args);
76 +
77 /*
78 * Construct a path into the git directory of repository `repo` and append it
79 * to the provided buffer `sb`.