diff options
| author | Patrick Steinhardt <ps@pks.im> | 2019-02-14 13:30:33 +0100 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2019-02-14 14:01:27 +0100 |
| commit | bf013fc0a8c318570b109ce1516f1c49b5cd37c4 (patch) | |
| tree | 564e7223b7cc92b992f272c066bdcbc0d64db2b3 /tests/refs/branches | |
| parent | efb20825e16f1b924986be4c6bc0410ce64aaa81 (diff) | |
| download | libgit2-bf013fc0a8c318570b109ce1516f1c49b5cd37c4.tar.gz | |
branch: fix `branch_is_checked_out` with bare repos
In a bare repository, HEAD usually points to the branch that is
considered the "default" branch. As the current implementation for
`git_branch_is_checked_out` only does a comparison of HEAD with the
branch that is to be checked, it will say that the branch pointed to by
HEAD in such a bare repo is checked out.
Fix this by skipping the main repo's HEAD when it is bare.
Diffstat (limited to 'tests/refs/branches')
| -rw-r--r-- | tests/refs/branches/checkedout.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/refs/branches/checkedout.c b/tests/refs/branches/checkedout.c index 2e195e2cd..d6dab2c0e 100644 --- a/tests/refs/branches/checkedout.c +++ b/tests/refs/branches/checkedout.c @@ -44,3 +44,10 @@ void test_refs_branches_checkedout__head_is_not_checked_out(void) assert_checked_out(repo, "HEAD", 0); cl_git_sandbox_cleanup(); } + +void test_refs_branches_checkedout__master_in_bare_repo_is_not_checked_out(void) +{ + repo = cl_git_sandbox_init("testrepo.git"); + assert_checked_out(repo, "refs/heads/master", 0); + cl_git_sandbox_cleanup(); +} |
