From cb3269c970db6766f8a953fee438b56119fd9847 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 11 Nov 2016 13:46:59 +0100 Subject: repository: add function to retrieve paths for repo items --- include/git2/repository.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'include/git2') diff --git a/include/git2/repository.h b/include/git2/repository.h index f60544553..74ce4c795 100644 --- a/include/git2/repository.h +++ b/include/git2/repository.h @@ -370,6 +370,42 @@ GIT_EXTERN(int) git_repository_head_unborn(git_repository *repo); */ GIT_EXTERN(int) git_repository_is_empty(git_repository *repo); +/** + * List of items which belong to the git repository layout + */ +typedef enum { + GIT_REPOSITORY_ITEM_GITDIR, + GIT_REPOSITORY_ITEM_WORKDIR, + GIT_REPOSITORY_ITEM_COMMONDIR, + GIT_REPOSITORY_ITEM_INDEX, + GIT_REPOSITORY_ITEM_OBJECTS, + GIT_REPOSITORY_ITEM_REFS, + GIT_REPOSITORY_ITEM_PACKED_REFS, + GIT_REPOSITORY_ITEM_REMOTES, + GIT_REPOSITORY_ITEM_CONFIG, + GIT_REPOSITORY_ITEM_INFO, + GIT_REPOSITORY_ITEM_HOOKS, + GIT_REPOSITORY_ITEM_LOGS, + GIT_REPOSITORY_ITEM_MODULES, + GIT_REPOSITORY_ITEM_WORKTREES +} git_repository_item_t; + +/** + * Get the location of a specific repository file or directory + * + * This function will retrieve the path of a specific repository + * item. It will thereby honor things like the repository's + * common directory, gitdir, etc. In case a file path cannot + * exist for a given item (e.g. the working directory of a bare + * repository), an error is returned. + * + * @param out Buffer to store the path at + * @param repo Repository to get path for + * @param item The repository item for which to retrieve the path + * @return 0 on success, otherwise a negative value + */ +GIT_EXTERN(int) git_repository_item_path(git_buf *out, git_repository *repo, git_repository_item_t item); + /** * Get the path of this repository * -- cgit v1.2.1