path: refactor repo_submodule_path()
family of functions
As explained in an earlier commit, we're refactoring path-related functions to provide a consistent interface for computing paths into the commondir, gitdir and worktree. Refactor the "submodule" family of functions accordingly. Note that in contrast to the other `repo_*_path()` families, we have to pass in the repository as a non-constant pointer. This is because we end up calling `repo_read_gitmodules()` deep down in the callstack, which may end up modifying the repository. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
f9467895d8
commit
f5c714e2a7
30
path.h
30
path.h
@ -93,20 +93,26 @@ const char *repo_worktree_path_replace(const struct repository *repo,
|
||||
__attribute__((format (printf, 3, 4)));
|
||||
|
||||
/*
|
||||
* Return a path into a submodule's git directory located at `path`. `path`
|
||||
* must only reference a submodule of the main repository (the_repository).
|
||||
* The `repo_submodule_path` family of functions will construct a path into a
|
||||
* submodule's git directory located at `path`. `path` must be a submodule path
|
||||
* as found in the index and must be part of the given repository.
|
||||
*
|
||||
* Returns a `NULL` pointer in case the submodule cannot be found.
|
||||
*/
|
||||
char *git_pathdup_submodule(const char *path, const char *fmt, ...)
|
||||
__attribute__((format (printf, 2, 3)));
|
||||
|
||||
/*
|
||||
* Construct a path into a submodule's git directory located at `path` and
|
||||
* append it to the provided buffer `sb`. `path` must only reference a
|
||||
* submodule of the main repository (the_repository).
|
||||
*/
|
||||
int strbuf_git_path_submodule(struct strbuf *sb, const char *path,
|
||||
const char *fmt, ...)
|
||||
char *repo_submodule_path(struct repository *repo,
|
||||
const char *path,
|
||||
const char *fmt, ...)
|
||||
__attribute__((format (printf, 3, 4)));
|
||||
const char *repo_submodule_path_append(struct repository *repo,
|
||||
struct strbuf *sb,
|
||||
const char *path,
|
||||
const char *fmt, ...)
|
||||
__attribute__((format (printf, 4, 5)));
|
||||
const char *repo_submodule_path_replace(struct repository *repo,
|
||||
struct strbuf *sb,
|
||||
const char *path,
|
||||
const char *fmt, ...)
|
||||
__attribute__((format (printf, 4, 5)));
|
||||
|
||||
void report_linked_checkout_garbage(struct repository *r);
|
||||
|
||||
|
Reference in New Issue
Block a user