diff options
author | Russell Belfer <rb@github.com> | 2014-09-15 21:59:23 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-09-15 21:59:23 -0700 |
commit | 1fbeb2f04c9a81a0fcacee5042d9e12a1e90052b (patch) | |
tree | e988bdf1b2a488efd9310b1d50abc2b512f3df80 /include/git2/sys | |
parent | 910cd2daa6af0f3af97d283eb4c6a0452688d067 (diff) | |
download | libgit2-rb/attr-with-bare.tar.gz |
Fix attribute lookup in index for bare reposrb/attr-with-bare
When using a bare repo with an index, libgit2 attempts to read
files from the index. It caches those files based on the path
to the file, specifically the path to the directory that contains
the file.
If there is no working directory, we use `git_path_dirname_r` to
get the path to the containing directory. However, for the
`.gitattributes` file in the root of the repository, this ends up
normalizing the containing path to `"."` instead of the empty
string and the lookup the `.gitattributes` data fails.
This adds a test of attribute lookups on bare repos and also
fixes the problem by simply rewriting `"."` to be `""`.
Diffstat (limited to 'include/git2/sys')
-rw-r--r-- | include/git2/sys/repository.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/git2/sys/repository.h b/include/git2/sys/repository.h index 36f8b5836..dd7b22e06 100644 --- a/include/git2/sys/repository.h +++ b/include/git2/sys/repository.h @@ -119,6 +119,19 @@ GIT_EXTERN(void) git_repository_set_refdb(git_repository *repo, git_refdb *refdb */ GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index); +/** + * Set a repository to be bare. + * + * Clear the working directory and set core.bare to true. You may also + * want to call `git_repository_set_index(repo, NULL)` since a bare repo + * typically does not have an index, but this function will not do that + * for you. + * + * @param repo Repo to make bare + * @return 0 on success, <0 on failure + */ +GIT_EXTERN(int) git_repository_set_bare(git_repository *repo); + /** @} */ GIT_END_DECL #endif |