path: add repo_git_path and strbuf_repo_git_path
Introduce 'repo_git_path' and 'strbuf_repo_git_path' which take a repository struct and constructs a path into the repository's git directory. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Jun 22, 2017 at 11:43 UTC
3181d86320f748b7b4f7a7133f2127e825eed702
2 files changed
+29
path.c
+21
@@ -416,6 +416,27 @@ static void do_git_path(const struct repository *repo,
416
strbuf_cleanup_path(buf);
417
}
418
419
+char *repo_git_path(const struct repository *repo,
420
+ const char *fmt, ...)
421
+{
422
+ struct strbuf path = STRBUF_INIT;
423
+ va_list args;
424
+ va_start(args, fmt);
425
+ do_git_path(repo, NULL, &path, fmt, args);
426
+ va_end(args);
427
+ return strbuf_detach(&path, NULL);
428
+}
429
+
430
+void strbuf_repo_git_path(struct strbuf *sb,
431
+ const struct repository *repo,
432
+ const char *fmt, ...)
433
+{
434
+ va_list args;
435
+ va_start(args, fmt);
436
+ do_git_path(repo, NULL, sb, fmt, args);
437
+ va_end(args);
438
+}
439
+
440
char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
441
{
442
va_list args;
path.h
+8
@@ -35,6 +35,14 @@ extern char *mkpathdup(const char *fmt, ...)
35
extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)
36
__attribute__((format (printf, 2, 3)));
37
38
+extern char *repo_git_path(const struct repository *repo,
39
+ const char *fmt, ...)
40
+ __attribute__((format (printf, 2, 3)));
41
+extern void strbuf_repo_git_path(struct strbuf *sb,
42
+ const struct repository *repo,
43
+ const char *fmt, ...)
44
+ __attribute__((format (printf, 3, 4)));
45
+
46
extern void report_linked_checkout_garbage(void);
47
48
/*