send-pack: convert remaining functions to struct object_id
[git/debian.git] / path.h
blob1ccd0373c9db8460c7ad7a3f9c5465f84408fd56
1 #ifndef PATH_H
2 #define PATH_H
4 struct repository;
6 /*
7 * The result to all functions which return statically allocated memory may be
8 * overwritten by another call to _any_ one of these functions. Consider using
9 * the safer variants which operate on strbufs or return allocated memory.
13 * Return a statically allocated path.
15 extern const char *mkpath(const char *fmt, ...)
16 __attribute__((format (printf, 1, 2)));
19 * Return a path.
21 extern char *mkpathdup(const char *fmt, ...)
22 __attribute__((format (printf, 1, 2)));
25 * Construct a path and place the result in the provided buffer `buf`.
27 extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
28 __attribute__((format (printf, 3, 4)));
31 * The `git_common_path` family of functions will construct a path into a
32 * repository's common git directory, which is shared by all worktrees.
36 * Constructs a path into the common git directory of repository `repo` and
37 * append it in the provided buffer `sb`.
39 extern void strbuf_git_common_path(struct strbuf *sb,
40 const struct repository *repo,
41 const char *fmt, ...)
42 __attribute__((format (printf, 3, 4)));
45 * Return a statically allocated path into the main repository's
46 * (the_repository) common git directory.
48 extern const char *git_common_path(const char *fmt, ...)
49 __attribute__((format (printf, 1, 2)));
53 * The `git_path` family of functions will construct a path into a repository's
54 * git directory.
56 * These functions will perform adjustments to the resultant path to account
57 * for special paths which are either considered common among worktrees (e.g.
58 * paths into the object directory) or have been explicitly set via an
59 * environment variable or config (e.g. path to the index file).
61 * For an exhaustive list of the adjustments made look at `common_list` and
62 * `adjust_git_path` in path.c.
66 * Return a path into the git directory of repository `repo`.
68 extern char *repo_git_path(const struct repository *repo,
69 const char *fmt, ...)
70 __attribute__((format (printf, 2, 3)));
73 * Construct a path into the git directory of repository `repo` and append it
74 * to the provided buffer `sb`.
76 extern void strbuf_repo_git_path(struct strbuf *sb,
77 const struct repository *repo,
78 const char *fmt, ...)
79 __attribute__((format (printf, 3, 4)));
82 * Return a statically allocated path into the main repository's
83 * (the_repository) git directory.
85 extern const char *git_path(const char *fmt, ...)
86 __attribute__((format (printf, 1, 2)));
89 * Return a path into the main repository's (the_repository) git directory.
91 extern char *git_pathdup(const char *fmt, ...)
92 __attribute__((format (printf, 1, 2)));
95 * Construct a path into the main repository's (the_repository) git directory
96 * and place it in the provided buffer `buf`, the contents of the buffer will
97 * be overridden.
99 extern char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
100 __attribute__((format (printf, 2, 3)));
103 * Construct a path into the main repository's (the_repository) git directory
104 * and append it to the provided buffer `sb`.
106 extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
107 __attribute__((format (printf, 2, 3)));
110 * Return a path into the worktree of repository `repo`.
112 * If the repository doesn't have a worktree NULL is returned.
114 extern char *repo_worktree_path(const struct repository *repo,
115 const char *fmt, ...)
116 __attribute__((format (printf, 2, 3)));
119 * Construct a path into the worktree of repository `repo` and append it
120 * to the provided buffer `sb`.
122 * If the repository doesn't have a worktree nothing will be appended to `sb`.
124 extern void strbuf_repo_worktree_path(struct strbuf *sb,
125 const struct repository *repo,
126 const char *fmt, ...)
127 __attribute__((format (printf, 3, 4)));
130 * Return a path into a submodule's git directory located at `path`. `path`
131 * must only reference a submodule of the main repository (the_repository).
133 extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)
134 __attribute__((format (printf, 2, 3)));
137 * Construct a path into a submodule's git directory located at `path` and
138 * append it to the provided buffer `sb`. `path` must only reference a
139 * submodule of the main repository (the_repository).
141 extern int strbuf_git_path_submodule(struct strbuf *sb, const char *path,
142 const char *fmt, ...)
143 __attribute__((format (printf, 3, 4)));
145 extern void report_linked_checkout_garbage(void);
148 * You can define a static memoized git path like:
150 * static GIT_PATH_FUNC(git_path_foo, "FOO");
152 * or use one of the global ones below.
154 #define GIT_PATH_FUNC(func, filename) \
155 const char *func(void) \
157 static char *ret; \
158 if (!ret) \
159 ret = git_pathdup(filename); \
160 return ret; \
163 const char *git_path_cherry_pick_head(void);
164 const char *git_path_revert_head(void);
165 const char *git_path_squash_msg(void);
166 const char *git_path_merge_msg(void);
167 const char *git_path_merge_rr(void);
168 const char *git_path_merge_mode(void);
169 const char *git_path_merge_head(void);
170 const char *git_path_fetch_head(void);
171 const char *git_path_shallow(void);
173 #endif /* PATH_H */