Guitar
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
Git Class Reference

#include <Git.h>

Classes

struct  RemoteInfo
 

Public Types

using ReflogItemList = QList< GitReflogItem >
 

Public Member Functions

 Git (GitContext const &cx, QString const &repodir, QString const &submodpath, QString const &sshkey)
 
 Git (Git &&r)=delete
 
 ~Git ()=default
 
void clearCommandCache ()
 
AbstractGitSession::Infogitinfo ()
 
AbstractGitSession::Info const & gitinfo () const
 
AbstractGitSession::Info2gitinfo2 ()
 
AbstractGitSession::Info2 const & gitinfo2 () const
 
QByteArray toQByteArray (const std::optional< GitResult > &var) const
 
bool isValidGitCommand () const
 
std::string resultStdString (const std::optional< GitResult > &var) const
 
QString resultQString (const std::optional< GitResult > &var) const
 
std::optional< GitResultexec_git (QString const &arg, AbstractGitSession::Option const &opt)
 
std::optional< GitResultgit (QString const &arg)
 
std::optional< GitResultgit_nolog (QString const &arg, AbstractPtyProcess *pty)
 
std::optional< GitResultgit_nochdir (QString const &arg, AbstractPtyProcess *pty)
 
bool remove (QString const &path)
 
void setWorkingRepositoryDir (QString const &repo, const QString &sshkey)
 
void setSubmodulePath (const QString &submodpath)
 
QString workingDir () const
 
QString const & sshKey () const
 
void setSshKey (const QString &sshkey)
 
QString getCurrentBranchName ()
 
bool isValidWorkingCopy () const
 
QString version ()
 
bool init ()
 
QStringList getUntrackedFiles ()
 
GitCommitItemList log_all (GitHash const &id, int maxcount)
 コミットログを取得する More...
 
GitCommitItemList log_file (QString const &path, int maxcount)
 
QStringList rev_list_all (GitHash const &id, int maxcount)
 
std::optional< GitCommitItemlog_signature (GitHash const &id)
 Git::log_signature. More...
 
GitCommitItemList log (int maxcount)
 
std::optional< GitCommitItemqueryCommitItem (const GitHash &id)
 
bool clone (GitCloneData const &data, AbstractPtyProcess *pty)
 
std::vector< GitFileStatusstatus_s ()
 
std::optional< QByteArray > cat_file (GitHash const &id)
 
void resetFile (QString const &path)
 
void resetAllFiles ()
 
void rm (QString const &path, bool rm_real_file)
 
void add_A ()
 
bool unstage_all ()
 
void stage (QString const &path)
 
bool stage (QStringList const &paths, AbstractPtyProcess *pty)
 
void unstage (QString const &path)
 
void unstage (QStringList const &paths)
 
bool pull (AbstractPtyProcess *pty=nullptr)
 
bool fetch (AbstractPtyProcess *pty=nullptr, bool prune=false)
 
QList< GitBranchbranches ()
 
QString diff (QString const &old_id, QString const &new_id)
 
QString diff_file (QString const &old_path, QString const &new_path)
 
std::vector< std::string > diff_name_only_head ()
 
std::string diff_full_index_head_file (const QString &file)
 
QList< GitDiffRawdiff_raw (GitHash const &old_id, GitHash const &new_id)
 
QString status ()
 
bool commit (QString const &text, bool sign, AbstractPtyProcess *pty)
 
bool commit_amend_m (QString const &text, bool sign, AbstractPtyProcess *pty)
 
bool revert (const GitHash &id)
 
bool push_tags (AbstractPtyProcess *pty=nullptr)
 
void remote_v (std::vector< GitRemote > *out)
 
void createBranch (QString const &name)
 
void checkoutBranch (QString const &name)
 
void mergeBranch (QString const &name, GitMergeFastForward ff, bool squash)
 
bool deleteBranch (QString const &name)
 
bool checkout (QString const &branch_name, QString const &id={})
 
bool checkout_detach (QString const &id)
 
void rebaseBranch (QString const &name)
 
void rebase_abort ()
 
bool isValidWorkingCopy (QString const &dir) const
 
QString diff_to_file (QString const &old_id, QString const &path)
 
QString errorMessage (const std::optional< GitResult > &var) const
 
GitHash rev_parse (QString const &name)
 
QList< GitTagtags ()
 
bool tag (QString const &name, GitHash const &id={})
 
bool delete_tag (QString const &name, bool remote)
 
void setRemoteURL (const GitRemote &remote)
 
void addRemoteURL (const GitRemote &remote)
 
void removeRemote (QString const &name)
 
QStringList getRemotes ()
 
GitUser getUser (GitSource purpose)
 
void setUser (GitUser const &user, bool global)
 
bool reset_head1 ()
 
bool reset_hard ()
 
bool clean_df ()
 
bool push_u (bool set_upstream, QString const &remote, QString const &branch, bool force, AbstractPtyProcess *pty)
 
QString objectType (const GitHash &id)
 
bool rm_cached (QString const &file)
 
void cherrypick (QString const &name)
 
QString getCherryPicking () const
 
QString getMessage (const QString &id)
 
bool reflog (ReflogItemList *out, int maxcount=100)
 
QByteArray blame (QString const &path)
 
QString signingKey (GitSource purpose)
 
bool setSigningKey (QString const &id, bool global)
 
GitSignPolicy signPolicy (GitSource source)
 
bool setSignPolicy (GitSource source, GitSignPolicy policy)
 
bool configGpgProgram (QString const &path, bool global)
 
QList< RemoteInfols_remote ()
 
bool stash ()
 
bool stash_apply ()
 
bool stash_drop ()
 
QList< GitSubmoduleItemsubmodules ()
 
bool submodule_add (const GitCloneData &data, bool force, AbstractPtyProcess *pty)
 
bool submodule_update (const GitSubmoduleUpdateData &data, AbstractPtyProcess *pty)
 
QString queryEntireCommitMessage (const GitHash &id)
 
QString getDefaultBranch ()
 
void setDefaultBranch (QString const &branchname)
 
void unsetDefaultBranch ()
 
QDateTime repositoryLastModifiedTime ()
 
std::optional< std::vector< GitFileItem > > ls (const QString &path)
 
std::optional< std::vector< char > > readfile (const QString &path)
 

Static Public Member Functions

static GitSignatureGrade evaluateSignature (char c)
 
static bool isUncommited (GitCommitItem const &item)
 
static GitCloneData preclone (QString const &url, QString const &path)
 
static std::optional< GitCommitItemparseCommit (QByteArray const &ba)
 

Private Member Functions

QStringList make_branch_list_ (const std::optional< GitResult > &result)
 
std::vector< GitFileStatusstatus_s_ ()
 
bool commit_ (QString const &msg, bool amend, bool sign, AbstractPtyProcess *pty)
 
 Git ()
 
void _init (const GitContext &cx)
 
QString encodeQuotedText (QString const &str)
 

Static Private Member Functions

static void parseAheadBehind (QString const &s, GitBranch *b)
 
static std::optional< GitCommitItemparseCommitItem (const QString &line)
 

Private Attributes

std::shared_ptr< AbstractGitSessionsession_
 

Friends

class GitRunner
 

Member Typedef Documentation

◆ ReflogItemList

Constructor & Destructor Documentation

◆ Git() [1/3]

Git::Git ( )
private

◆ Git() [2/3]

Git::Git ( GitContext const &  cx,
QString const &  repodir,
QString const &  submodpath,
QString const &  sshkey 
)
Here is the call graph for this function:

◆ Git() [3/3]

Git::Git ( Git &&  r)
delete

◆ ~Git()

Git::~Git ( )
default

Member Function Documentation

◆ _init()

void Git::_init ( const GitContext cx)
private
Here is the call graph for this function:

◆ add_A()

void Git::add_A ( )
Here is the call graph for this function:

◆ addRemoteURL()

void Git::addRemoteURL ( const GitRemote remote)
Here is the call graph for this function:

◆ blame()

QByteArray Git::blame ( QString const &  path)
Here is the call graph for this function:

◆ branches()

QList< GitBranch > Git::branches ( )
Here is the call graph for this function:

◆ cat_file()

std::optional< QByteArray > Git::cat_file ( GitHash const &  id)
Here is the call graph for this function:

◆ checkout()

bool Git::checkout ( QString const &  branch_name,
QString const &  id = {} 
)
Here is the call graph for this function:

◆ checkout_detach()

bool Git::checkout_detach ( QString const &  id)
Here is the call graph for this function:

◆ checkoutBranch()

void Git::checkoutBranch ( QString const &  name)
Here is the call graph for this function:

◆ cherrypick()

void Git::cherrypick ( QString const &  name)
Here is the call graph for this function:

◆ clean_df()

bool Git::clean_df ( )
Here is the call graph for this function:

◆ clearCommandCache()

void Git::clearCommandCache ( )

◆ clone()

bool Git::clone ( GitCloneData const &  data,
AbstractPtyProcess pty 
)
Here is the call graph for this function:

◆ commit()

bool Git::commit ( QString const &  text,
bool  sign,
AbstractPtyProcess pty 
)
Here is the call graph for this function:

◆ commit_()

bool Git::commit_ ( QString const &  msg,
bool  amend,
bool  sign,
AbstractPtyProcess pty 
)
private
Here is the call graph for this function:

◆ commit_amend_m()

bool Git::commit_amend_m ( QString const &  text,
bool  sign,
AbstractPtyProcess pty 
)
Here is the call graph for this function:

◆ configGpgProgram()

bool Git::configGpgProgram ( QString const &  path,
bool  global 
)
Here is the call graph for this function:

◆ createBranch()

void Git::createBranch ( QString const &  name)
Here is the call graph for this function:

◆ delete_tag()

bool Git::delete_tag ( QString const &  name,
bool  remote 
)
Here is the call graph for this function:

◆ deleteBranch()

bool Git::deleteBranch ( QString const &  name)
Here is the call graph for this function:

◆ diff()

QString Git::diff ( QString const &  old_id,
QString const &  new_id 
)
Here is the call graph for this function:

◆ diff_file()

QString Git::diff_file ( QString const &  old_path,
QString const &  new_path 
)
Here is the call graph for this function:

◆ diff_full_index_head_file()

std::string Git::diff_full_index_head_file ( const QString &  file)
Here is the call graph for this function:

◆ diff_name_only_head()

std::vector< std::string > Git::diff_name_only_head ( )
Here is the call graph for this function:

◆ diff_raw()

QList< GitDiffRaw > Git::diff_raw ( GitHash const &  old_id,
GitHash const &  new_id 
)
Here is the call graph for this function:

◆ diff_to_file()

QString Git::diff_to_file ( QString const &  old_id,
QString const &  path 
)
Here is the call graph for this function:

◆ encodeQuotedText()

QString Git::encodeQuotedText ( QString const &  str)
private

◆ errorMessage()

QString Git::errorMessage ( const std::optional< GitResult > &  var) const
Here is the call graph for this function:

◆ evaluateSignature()

static GitSignatureGrade Git::evaluateSignature ( char  c)
inlinestatic

◆ exec_git()

std::optional<GitResult> Git::exec_git ( QString const &  arg,
AbstractGitSession::Option const &  opt 
)
inline

◆ fetch()

bool Git::fetch ( AbstractPtyProcess pty = nullptr,
bool  prune = false 
)
Here is the call graph for this function:

◆ getCherryPicking()

QString Git::getCherryPicking ( ) const
Here is the call graph for this function:

◆ getCurrentBranchName()

QString Git::getCurrentBranchName ( )
Here is the call graph for this function:

◆ getDefaultBranch()

QString Git::getDefaultBranch ( )
Here is the call graph for this function:

◆ getMessage()

QString Git::getMessage ( const QString &  id)
Here is the call graph for this function:

◆ getRemotes()

QStringList Git::getRemotes ( )
Here is the call graph for this function:

◆ getUntrackedFiles()

QStringList Git::getUntrackedFiles ( )
Here is the call graph for this function:

◆ getUser()

GitUser Git::getUser ( GitSource  purpose)
Here is the call graph for this function:

◆ git()

std::optional<GitResult> Git::git ( QString const &  arg)
inline
Here is the call graph for this function:

◆ git_nochdir()

std::optional<GitResult> Git::git_nochdir ( QString const &  arg,
AbstractPtyProcess pty 
)
inline
Here is the call graph for this function:

◆ git_nolog()

std::optional<GitResult> Git::git_nolog ( QString const &  arg,
AbstractPtyProcess pty 
)
inline
Here is the call graph for this function:

◆ gitinfo() [1/2]

AbstractGitSession::Info& Git::gitinfo ( )
inline

◆ gitinfo() [2/2]

AbstractGitSession::Info const& Git::gitinfo ( ) const
inline

◆ gitinfo2() [1/2]

AbstractGitSession::Info2& Git::gitinfo2 ( )
inline

◆ gitinfo2() [2/2]

AbstractGitSession::Info2 const& Git::gitinfo2 ( ) const
inline

◆ init()

bool Git::init ( )
Here is the call graph for this function:

◆ isUncommited()

static bool Git::isUncommited ( GitCommitItem const &  item)
inlinestatic
Here is the call graph for this function:

◆ isValidGitCommand()

bool Git::isValidGitCommand ( ) const
inline

◆ isValidWorkingCopy() [1/2]

bool Git::isValidWorkingCopy ( ) const
Here is the call graph for this function:

◆ isValidWorkingCopy() [2/2]

bool Git::isValidWorkingCopy ( QString const &  dir) const

◆ log()

GitCommitItemList Git::log ( int  maxcount)
Here is the call graph for this function:

◆ log_all()

GitCommitItemList Git::log_all ( GitHash const &  id,
int  maxcount 
)

コミットログを取得する

Parameters
idコミットID
maxcount最大アイテム数
Returns
Here is the call graph for this function:

◆ log_file()

GitCommitItemList Git::log_file ( QString const &  path,
int  maxcount 
)
Here is the call graph for this function:

◆ log_signature()

std::optional< GitCommitItem > Git::log_signature ( GitHash const &  id)

Git::log_signature.

Parameters
idコミットID
Returns

コミットに関連する署名情報を取得する

Here is the call graph for this function:

◆ ls()

std::optional< std::vector< GitFileItem > > Git::ls ( const QString &  path)

◆ ls_remote()

QList< Git::RemoteInfo > Git::ls_remote ( )
Here is the call graph for this function:

◆ make_branch_list_()

QStringList Git::make_branch_list_ ( const std::optional< GitResult > &  result)
private
Here is the call graph for this function:

◆ mergeBranch()

void Git::mergeBranch ( QString const &  name,
GitMergeFastForward  ff,
bool  squash 
)
Here is the call graph for this function:

◆ objectType()

QString Git::objectType ( const GitHash id)
Here is the call graph for this function:

◆ parseAheadBehind()

void Git::parseAheadBehind ( QString const &  s,
GitBranch b 
)
staticprivate

◆ parseCommit()

std::optional< GitCommitItem > Git::parseCommit ( QByteArray const &  ba)
static
Here is the call graph for this function:

◆ parseCommitItem()

std::optional< GitCommitItem > Git::parseCommitItem ( const QString &  line)
staticprivate
Here is the call graph for this function:

◆ preclone()

GitCloneData Git::preclone ( QString const &  url,
QString const &  path 
)
static

◆ pull()

bool Git::pull ( AbstractPtyProcess pty = nullptr)
Here is the call graph for this function:

◆ push_tags()

bool Git::push_tags ( AbstractPtyProcess pty = nullptr)
Here is the call graph for this function:

◆ push_u()

bool Git::push_u ( bool  set_upstream,
QString const &  remote,
QString const &  branch,
bool  force,
AbstractPtyProcess pty 
)
Here is the call graph for this function:

◆ queryCommitItem()

std::optional< GitCommitItem > Git::queryCommitItem ( const GitHash id)
Here is the call graph for this function:

◆ queryEntireCommitMessage()

QString Git::queryEntireCommitMessage ( const GitHash id)
Here is the call graph for this function:

◆ readfile()

std::optional< std::vector< char > > Git::readfile ( const QString &  path)

◆ rebase_abort()

void Git::rebase_abort ( )
Here is the call graph for this function:

◆ rebaseBranch()

void Git::rebaseBranch ( QString const &  name)
Here is the call graph for this function:

◆ reflog()

bool Git::reflog ( ReflogItemList out,
int  maxcount = 100 
)
Here is the call graph for this function:

◆ remote_v()

void Git::remote_v ( std::vector< GitRemote > *  out)
Here is the call graph for this function:

◆ remove()

bool Git::remove ( QString const &  path)
inline

◆ removeRemote()

void Git::removeRemote ( QString const &  name)
Here is the call graph for this function:

◆ repositoryLastModifiedTime()

QDateTime Git::repositoryLastModifiedTime ( )
Here is the call graph for this function:

◆ reset_hard()

bool Git::reset_hard ( )
Here is the call graph for this function:

◆ reset_head1()

bool Git::reset_head1 ( )
Here is the call graph for this function:

◆ resetAllFiles()

void Git::resetAllFiles ( )
Here is the call graph for this function:

◆ resetFile()

void Git::resetFile ( QString const &  path)
Here is the call graph for this function:

◆ resultQString()

QString Git::resultQString ( const std::optional< GitResult > &  var) const
Here is the call graph for this function:

◆ resultStdString()

std::string Git::resultStdString ( const std::optional< GitResult > &  var) const
Here is the call graph for this function:

◆ rev_list_all()

QStringList Git::rev_list_all ( GitHash const &  id,
int  maxcount 
)
Here is the call graph for this function:

◆ rev_parse()

GitHash Git::rev_parse ( QString const &  name)
Here is the call graph for this function:

◆ revert()

bool Git::revert ( const GitHash id)
Here is the call graph for this function:

◆ rm()

void Git::rm ( QString const &  path,
bool  rm_real_file 
)
Here is the call graph for this function:

◆ rm_cached()

bool Git::rm_cached ( QString const &  file)
Here is the call graph for this function:

◆ setDefaultBranch()

void Git::setDefaultBranch ( QString const &  branchname)
Here is the call graph for this function:

◆ setRemoteURL()

void Git::setRemoteURL ( const GitRemote remote)
Here is the call graph for this function:

◆ setSigningKey()

bool Git::setSigningKey ( QString const &  id,
bool  global 
)
Here is the call graph for this function:

◆ setSignPolicy()

bool Git::setSignPolicy ( GitSource  source,
GitSignPolicy  policy 
)
Here is the call graph for this function:

◆ setSshKey()

void Git::setSshKey ( const QString &  sshkey)
Here is the call graph for this function:

◆ setSubmodulePath()

void Git::setSubmodulePath ( const QString &  submodpath)
Here is the call graph for this function:

◆ setUser()

void Git::setUser ( GitUser const &  user,
bool  global 
)
Here is the call graph for this function:

◆ setWorkingRepositoryDir()

void Git::setWorkingRepositoryDir ( QString const &  repo,
const QString &  sshkey 
)
Here is the call graph for this function:

◆ signingKey()

QString Git::signingKey ( GitSource  purpose)
Here is the call graph for this function:

◆ signPolicy()

GitSignPolicy Git::signPolicy ( GitSource  source)
Here is the call graph for this function:

◆ sshKey()

QString const & Git::sshKey ( ) const
Here is the call graph for this function:

◆ stage() [1/2]

void Git::stage ( QString const &  path)
Here is the call graph for this function:

◆ stage() [2/2]

bool Git::stage ( QStringList const &  paths,
AbstractPtyProcess pty 
)
Here is the call graph for this function:

◆ stash()

bool Git::stash ( )
Here is the call graph for this function:

◆ stash_apply()

bool Git::stash_apply ( )
Here is the call graph for this function:

◆ stash_drop()

bool Git::stash_drop ( )
Here is the call graph for this function:

◆ status()

QString Git::status ( )
Here is the call graph for this function:

◆ status_s()

std::vector< GitFileStatus > Git::status_s ( )
Here is the call graph for this function:

◆ status_s_()

std::vector< GitFileStatus > Git::status_s_ ( )
private
Here is the call graph for this function:

◆ submodule_add()

bool Git::submodule_add ( const GitCloneData data,
bool  force,
AbstractPtyProcess pty 
)
Here is the call graph for this function:

◆ submodule_update()

bool Git::submodule_update ( const GitSubmoduleUpdateData data,
AbstractPtyProcess pty 
)
Here is the call graph for this function:

◆ submodules()

QList< GitSubmoduleItem > Git::submodules ( )
Here is the call graph for this function:

◆ tag()

bool Git::tag ( QString const &  name,
GitHash const &  id = {} 
)
Here is the call graph for this function:

◆ tags()

QList< GitTag > Git::tags ( )
Here is the call graph for this function:

◆ toQByteArray()

QByteArray Git::toQByteArray ( const std::optional< GitResult > &  var) const
Here is the call graph for this function:

◆ unsetDefaultBranch()

void Git::unsetDefaultBranch ( )
Here is the call graph for this function:

◆ unstage() [1/2]

void Git::unstage ( QString const &  path)
Here is the call graph for this function:

◆ unstage() [2/2]

void Git::unstage ( QStringList const &  paths)
Here is the call graph for this function:

◆ unstage_all()

bool Git::unstage_all ( )
Here is the call graph for this function:

◆ version()

QString Git::version ( )
Here is the call graph for this function:

◆ workingDir()

QString Git::workingDir ( ) const
inline

Friends And Related Function Documentation

◆ GitRunner

friend class GitRunner
friend

Member Data Documentation

◆ session_

std::shared_ptr<AbstractGitSession> Git::session_
private

The documentation for this class was generated from the following files: