diff options
Diffstat (limited to 'src/repo.cpp')
-rw-r--r-- | src/repo.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/repo.cpp b/src/repo.cpp index 4059897..0da7e4a 100644 --- a/src/repo.cpp +++ b/src/repo.cpp @@ -11,11 +11,23 @@ std::string operator/(const std::string & a, const std::string & b) GitFS::Repo::Repo(const PropertyReader & properties) : repo(Git::RepositoryOpenBare(properties("gitdir"))), - commit(Git::CommitLookup(repo, Git::OidParse(properties("commit")))), - tree(Git::TreeLookup(repo, *git_commit_tree_id(commit.get()))), + commitish(properties("commitish") / "master"), gid(properties("gid") / "root"), uid(properties("uid") / "root") { + git_oid commitId; + if (commitish.length() == GIT_OID_HEXSZ) { + commitId = Git::OidParse(commitish); + } + else { + auto ref = Git::Commitish(repo, commitish); + isBranch = git_reference_is_branch(ref.get()); + ref = Git::Resolve(ref); + commitId = *git_reference_target(ref.get()); + } + + commit = Git::CommitLookup(repo, commitId); + tree = Git::TreeLookup(repo, *git_commit_tree_id(commit.get())); } void |