Skip to content

Commit

Permalink
Add some information getters to repo class
Browse files Browse the repository at this point in the history
  • Loading branch information
ropez committed Nov 21, 2011
1 parent 6364946 commit e7d9331
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/qgitrepository.cpp
Expand Up @@ -119,6 +119,46 @@ QGitRef QGitRepository::head()
return QGitRef(ref);
}

bool QGitRepository::isHeadDetached() const
{
return git_repository_head_detached(data()) == 1;
}

bool QGitRepository::isHeadOrphan() const
{
return git_repository_head_orphan(data()) == 1;
}

bool QGitRepository::isEmpty() const
{
return git_repository_is_empty(data()) == 1;
}

bool QGitRepository::isBare() const
{
return git_repository_is_bare(data()) == 1;
}

QString QGitRepository::path() const
{
return QFile::decodeName(git_repository_path(data(), GIT_REPO_PATH));
}

QString QGitRepository::indexPath() const
{
return QFile::decodeName(git_repository_path(data(), GIT_REPO_PATH_INDEX));
}

QString QGitRepository::databasePath() const
{
return QFile::decodeName(git_repository_path(data(), GIT_REPO_PATH_ODB));
}

QString QGitRepository::workDirPath() const
{
return QFile::decodeName(git_repository_path(data(), GIT_REPO_PATH_WORKDIR));
}

QGitRef QGitRepository::lookupRef(const QString& name)
{
git_reference *ref = 0;
Expand Down
49 changes: 49 additions & 0 deletions src/qgitrepository.h
Expand Up @@ -166,6 +166,55 @@ namespace LibQGit2
*/
QGitRef head();

/**
* Check if a repository's HEAD is detached
*
* A repository's HEAD is detached when it points directly to a commit
* instead of a branch.
*/
bool isHeadDetached() const;

/**
* Check if the current branch is an orphan
*
* An orphan branch is one named from HEAD but which doesn't exist in
* the refs namespace, because it doesn't have any commit to point to.
*/
bool isHeadOrphan() const;

/**
* Check if a repository is empty
*
* An empty repository has just been initialized and contains
* no commits.
*/
bool isEmpty() const;

/**
* Check if a repository is bare
*/
bool isBare() const;

/**
* Get the path to the repository
*/
QString path() const;

/**
* Get the path to the index
*/
QString indexPath() const;

/**
* Get the path to the ODB
*/
QString databasePath() const;

/**
* Get the path to the working directory
*/
QString workDirPath() const;

/**
* Lookup a reference by its name in a repository.
*/
Expand Down

0 comments on commit e7d9331

Please sign in to comment.