Skip to content

Commit b6c6bfe

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 92a29c2 commit b6c6bfe

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

path.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ static void strbuf_worktree_gitdir(struct strbuf *buf,
417417
strbuf_git_common_path(buf, repo, "worktrees/%s", wt->id);
418418
}
419419

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)
423423
{
424424
int gitdir_len;
425425
strbuf_worktree_gitdir(buf, repo, wt);
@@ -438,7 +438,7 @@ char *repo_git_path(const struct repository *repo,
438438
struct strbuf path = STRBUF_INIT;
439439
va_list args;
440440
va_start(args, fmt);
441-
do_git_path(repo, NULL, &path, fmt, args);
441+
repo_git_pathv(repo, NULL, &path, fmt, args);
442442
va_end(args);
443443
return strbuf_detach(&path, NULL);
444444
}
@@ -449,7 +449,7 @@ void strbuf_repo_git_path(struct strbuf *sb,
449449
{
450450
va_list args;
451451
va_start(args, fmt);
452-
do_git_path(repo, NULL, sb, fmt, args);
452+
repo_git_pathv(repo, NULL, sb, fmt, args);
453453
va_end(args);
454454
}
455455

@@ -458,7 +458,7 @@ char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
458458
va_list args;
459459
strbuf_reset(buf);
460460
va_start(args, fmt);
461-
do_git_path(the_repository, NULL, buf, fmt, args);
461+
repo_git_pathv(the_repository, NULL, buf, fmt, args);
462462
va_end(args);
463463
return buf->buf;
464464
}
@@ -467,7 +467,7 @@ void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
467467
{
468468
va_list args;
469469
va_start(args, fmt);
470-
do_git_path(the_repository, NULL, sb, fmt, args);
470+
repo_git_pathv(the_repository, NULL, sb, fmt, args);
471471
va_end(args);
472472
}
473473

@@ -476,7 +476,7 @@ const char *git_path(const char *fmt, ...)
476476
struct strbuf *pathname = get_pathname();
477477
va_list args;
478478
va_start(args, fmt);
479-
do_git_path(the_repository, NULL, pathname, fmt, args);
479+
repo_git_pathv(the_repository, NULL, pathname, fmt, args);
480480
va_end(args);
481481
return pathname->buf;
482482
}
@@ -486,7 +486,7 @@ char *git_pathdup(const char *fmt, ...)
486486
struct strbuf path = STRBUF_INIT;
487487
va_list args;
488488
va_start(args, fmt);
489-
do_git_path(the_repository, NULL, &path, fmt, args);
489+
repo_git_pathv(the_repository, NULL, &path, fmt, args);
490490
va_end(args);
491491
return strbuf_detach(&path, NULL);
492492
}
@@ -517,7 +517,7 @@ const char *worktree_git_path(const struct worktree *wt, const char *fmt, ...)
517517
struct strbuf *pathname = get_pathname();
518518
va_list args;
519519
va_start(args, fmt);
520-
do_git_path(the_repository, wt, pathname, fmt, args);
520+
repo_git_pathv(the_repository, wt, pathname, fmt, args);
521521
va_end(args);
522522
return pathname->buf;
523523
}

path.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ char *repo_git_path(const struct repository *repo,
6666
const char *fmt, ...)
6767
__attribute__((format (printf, 2, 3)));
6868

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+
6977
/*
7078
* Construct a path into the git directory of repository `repo` and append it
7179
* to the provided buffer `sb`.

0 commit comments

Comments
 (0)