Commit d02cf564 by Patrick Steinhardt

repository: constify several repo parameters for getters

Several functions to retrieve variables from a repository only return
immutable values, which allows us to actually constify the passed-in
repository parameter. Do so to help a later patch, which will only have
access to a constant repository.
parent f38ce9b6
...@@ -440,7 +440,7 @@ typedef enum { ...@@ -440,7 +440,7 @@ typedef enum {
* @param item The repository item for which to retrieve the path * @param item The repository item for which to retrieve the path
* @return 0, GIT_ENOTFOUND if the path cannot exist or an error code * @return 0, GIT_ENOTFOUND if the path cannot exist or an error code
*/ */
GIT_EXTERN(int) git_repository_item_path(git_buf *out, git_repository *repo, git_repository_item_t item); GIT_EXTERN(int) git_repository_item_path(git_buf *out, const git_repository *repo, git_repository_item_t item);
/** /**
* Get the path of this repository * Get the path of this repository
...@@ -451,7 +451,7 @@ GIT_EXTERN(int) git_repository_item_path(git_buf *out, git_repository *repo, git ...@@ -451,7 +451,7 @@ GIT_EXTERN(int) git_repository_item_path(git_buf *out, git_repository *repo, git
* @param repo A repository object * @param repo A repository object
* @return the path to the repository * @return the path to the repository
*/ */
GIT_EXTERN(const char *) git_repository_path(git_repository *repo); GIT_EXTERN(const char *) git_repository_path(const git_repository *repo);
/** /**
* Get the path of the working directory for this repository * Get the path of the working directory for this repository
...@@ -462,7 +462,7 @@ GIT_EXTERN(const char *) git_repository_path(git_repository *repo); ...@@ -462,7 +462,7 @@ GIT_EXTERN(const char *) git_repository_path(git_repository *repo);
* @param repo A repository object * @param repo A repository object
* @return the path to the working dir, if it exists * @return the path to the working dir, if it exists
*/ */
GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo); GIT_EXTERN(const char *) git_repository_workdir(const git_repository *repo);
/** /**
* Get the path of the shared common directory for this repository * Get the path of the shared common directory for this repository
...@@ -473,7 +473,7 @@ GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo); ...@@ -473,7 +473,7 @@ GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo);
* @param repo A repository object * @param repo A repository object
* @return the path to the common dir * @return the path to the common dir
*/ */
GIT_EXTERN(const char *) git_repository_commondir(git_repository *repo); GIT_EXTERN(const char *) git_repository_commondir(const git_repository *repo);
/** /**
* Set the path to the working directory for this repository * Set the path to the working directory for this repository
...@@ -501,7 +501,7 @@ GIT_EXTERN(int) git_repository_set_workdir( ...@@ -501,7 +501,7 @@ GIT_EXTERN(int) git_repository_set_workdir(
* @param repo Repo to test * @param repo Repo to test
* @return 1 if the repository is bare, 0 otherwise. * @return 1 if the repository is bare, 0 otherwise.
*/ */
GIT_EXTERN(int) git_repository_is_bare(git_repository *repo); GIT_EXTERN(int) git_repository_is_bare(const git_repository *repo);
/** /**
* Check if a repository is a linked work tree * Check if a repository is a linked work tree
...@@ -509,7 +509,7 @@ GIT_EXTERN(int) git_repository_is_bare(git_repository *repo); ...@@ -509,7 +509,7 @@ GIT_EXTERN(int) git_repository_is_bare(git_repository *repo);
* @param repo Repo to test * @param repo Repo to test
* @return 1 if the repository is a linked work tree, 0 otherwise. * @return 1 if the repository is a linked work tree, 0 otherwise.
*/ */
GIT_EXTERN(int) git_repository_is_worktree(git_repository *repo); GIT_EXTERN(int) git_repository_is_worktree(const git_repository *repo);
/** /**
* Get the configuration file for this repository. * Get the configuration file for this repository.
......
...@@ -2256,7 +2256,7 @@ int git_repository_is_empty(git_repository *repo) ...@@ -2256,7 +2256,7 @@ int git_repository_is_empty(git_repository *repo)
return is_empty; return is_empty;
} }
int git_repository_item_path(git_buf *out, git_repository *repo, git_repository_item_t item) int git_repository_item_path(git_buf *out, const git_repository *repo, git_repository_item_t item)
{ {
const char *parent; const char *parent;
...@@ -2296,13 +2296,13 @@ int git_repository_item_path(git_buf *out, git_repository *repo, git_repository_ ...@@ -2296,13 +2296,13 @@ int git_repository_item_path(git_buf *out, git_repository *repo, git_repository_
return 0; return 0;
} }
const char *git_repository_path(git_repository *repo) const char *git_repository_path(const git_repository *repo)
{ {
assert(repo); assert(repo);
return repo->gitdir; return repo->gitdir;
} }
const char *git_repository_workdir(git_repository *repo) const char *git_repository_workdir(const git_repository *repo)
{ {
assert(repo); assert(repo);
...@@ -2312,7 +2312,7 @@ const char *git_repository_workdir(git_repository *repo) ...@@ -2312,7 +2312,7 @@ const char *git_repository_workdir(git_repository *repo)
return repo->workdir; return repo->workdir;
} }
const char *git_repository_commondir(git_repository *repo) const char *git_repository_commondir(const git_repository *repo)
{ {
assert(repo); assert(repo);
return repo->commondir; return repo->commondir;
...@@ -2362,13 +2362,13 @@ int git_repository_set_workdir( ...@@ -2362,13 +2362,13 @@ int git_repository_set_workdir(
return error; return error;
} }
int git_repository_is_bare(git_repository *repo) int git_repository_is_bare(const git_repository *repo)
{ {
assert(repo); assert(repo);
return repo->is_bare; return repo->is_bare;
} }
int git_repository_is_worktree(git_repository *repo) int git_repository_is_worktree(const git_repository *repo)
{ {
assert(repo); assert(repo);
return repo->is_worktree; return repo->is_worktree;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment