path: create path.h
[git/git.git] / path.h
1 #ifndef PATH_H
2 #define PATH_H
3
4 /*
5 * Return a statically allocated filename, either generically (mkpath), in
6 * the repository directory (git_path), or in a submodule's repository
7 * directory (git_path_submodule). In all cases, note that the result
8 * may be overwritten by another call to _any_ of the functions. Consider
9 * using the safer "dup" or "strbuf" formats below (in some cases, the
10 * unsafe versions have already been removed).
11 */
12 extern const char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
13 extern const char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
14 extern const char *git_common_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
15
16 extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
17 __attribute__((format (printf, 3, 4)));
18 extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
19 __attribute__((format (printf, 2, 3)));
20 extern void strbuf_git_common_path(struct strbuf *sb, const char *fmt, ...)
21 __attribute__((format (printf, 2, 3)));
22 extern char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
23 __attribute__((format (printf, 2, 3)));
24 extern int strbuf_git_path_submodule(struct strbuf *sb, const char *path,
25 const char *fmt, ...)
26 __attribute__((format (printf, 3, 4)));
27 extern char *git_pathdup(const char *fmt, ...)
28 __attribute__((format (printf, 1, 2)));
29 extern char *mkpathdup(const char *fmt, ...)
30 __attribute__((format (printf, 1, 2)));
31 extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)
32 __attribute__((format (printf, 2, 3)));
33
34 extern void report_linked_checkout_garbage(void);
35
36 /*
37 * You can define a static memoized git path like:
38 *
39 * static GIT_PATH_FUNC(git_path_foo, "FOO");
40 *
41 * or use one of the global ones below.
42 */
43 #define GIT_PATH_FUNC(func, filename) \
44 const char *func(void) \
45 { \
46 static char *ret; \
47 if (!ret) \
48 ret = git_pathdup(filename); \
49 return ret; \
50 }
51
52 const char *git_path_cherry_pick_head(void);
53 const char *git_path_revert_head(void);
54 const char *git_path_squash_msg(void);
55 const char *git_path_merge_msg(void);
56 const char *git_path_merge_rr(void);
57 const char *git_path_merge_mode(void);
58 const char *git_path_merge_head(void);
59 const char *git_path_fetch_head(void);
60 const char *git_path_shallow(void);
61
62 #endif /* PATH_H */