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 = std::vector< GitReflogItem >
 

Public Member Functions

 Git (GitContext const &cx, std::string const &repodir, std::string const &submodpath, std::string const &sshkey)
 
 Git (Git &&r)=delete
 
 ~Git ()=default
 
void clearCommandCache ()
 
void clearObjectCache ()
 
AbstractGitSession::Infogitinfo ()
 
AbstractGitSession::Info const & gitinfo () const
 
std::vector< char > toByteArray (const std::optional< GitResult > &var) const
 
bool isValidGitCommand () const
 
std::string resultStdString (const std::optional< GitResult > &var) const
 
std::optional< GitResultexec_git (std::string const &arg, AbstractGitSession::Option const &opt)
 
std::optional< GitResultgit (std::string const &arg)
 
std::optional< GitResultgit_nolog (std::string const &arg, AbstractPtyProcess *pty)
 
std::optional< GitResultgit_nochdir (std::string const &arg, AbstractPtyProcess *pty)
 
bool remove (std::string const &path)
 
void setWorkingRepositoryDir (std::string const &repo, std::string const &sshkey)
 
void setSubmodulePath (std::string const &submodpath)
 
std::string workingDir () const
 
const std::string & sshKey () const
 
void setSshKey (std::string const &sshkey)
 
std::string getCurrentBranchName ()
 
bool isValidWorkingCopy () const
 
std::string version ()
 
bool init ()
 
std::vector< std::string > getUntrackedFiles ()
 
GitCommitItemList log_file (const std::string &path, int maxcount)
 コミットログを取得する More...
 
GitCommitItemList log_all (GitHash const &id, int maxcount)
 
std::vector< GitHashrev_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_u (std::string *out=nullptr)
 
std::optional< std::vector< char > > cat_file (GitHash const &id)
 
void resetFile (const std::string &path)
 
void resetAllFiles ()
 
void rm (const std::string &path, bool rm_real_file)
 
void add_A ()
 
bool unstage_all ()
 
void stage (const std::string &path)
 
bool stage (std::vector< std::string > const &paths, AbstractPtyProcess *pty)
 
void unstage (const std::string &path)
 
void unstage (std::vector< std::string > const &paths)
 
bool pull (AbstractPtyProcess *pty=nullptr)
 
bool fetch (AbstractPtyProcess *pty=nullptr, bool prune=false)
 
std::vector< GitBranchbranches ()
 
std::string diff (const std::string &old_id, const std::string &new_id, const GitDiffOption &opt)
 
std::string diff_file (const std::string &old_path, const std::string &new_path, const GitDiffOption &opt)
 
std::string diff_to_file (const std::string &old_id, const std::string &path, const GitDiffOption &opt)
 
std::vector< std::string > diff_name_only_head ()
 
std::string diff_full_index_head_file (const std::string &file)
 
std::vector< GitDiffRawdiff_raw (GitHash const &old_id, GitHash const &new_id)
 
std::string status ()
 
bool commit (const std::string &text, bool sign, AbstractPtyProcess *pty)
 
bool commit_amend_m (const std::string &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 (const std::string &name)
 
void checkoutBranch (std::string const &name)
 
void mergeBranch (const std::string &name, GitMergeFastForward ff, bool squash)
 
bool deleteBranch (std::string const &name)
 
bool checkout (const std::string &branch_name, const std::string &id={})
 
bool checkout_detach (std::string const &id)
 
void rebaseBranch (const std::string &name)
 
bool rebase_continue ()
 
bool rebase_abort ()
 
bool rebase_quit ()
 
bool isValidWorkingCopy (const std::string &dir) const
 
std::string errorMessage (const std::optional< GitResult > &var) const
 
GitHash rev_parse (std::string const &name)
 
std::vector< GitTagtags ()
 
bool tag (const std::string &name, GitHash const &id={})
 
bool delete_tag (const std::string &name, bool remote)
 
void setRemoteURL (const GitRemote &remote)
 
void addRemoteURL (const GitRemote &remote)
 
void removeRemote (const std::string &name)
 
std::vector< std::string > 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, std::string const &remote, std::string const &branch, bool force, AbstractPtyProcess *pty)
 
std::string objectType (const GitHash &id)
 
bool rm_cached (const std::string &file)
 
void cherrypick (std::string const &name)
 
std::string getCherryPicking () const
 
std::string getMessage (const std::string &id)
 
bool reflog (ReflogItemList *out, int maxcount=100)
 
std::vector< char > blame (const std::string &path)
 
std::string signingKey (GitSource purpose)
 
bool setSigningKey (const std::string &id, bool global)
 
GitSignPolicy signPolicy (GitSource source)
 
bool setSignPolicy (GitSource source, GitSignPolicy policy)
 
bool configGpgProgram (const std::string &path, bool global)
 
std::vector< RemoteInfols_remote ()
 
std::string rev_parse_show_toplevel ()
 
bool stash ()
 
bool stash_apply ()
 
bool stash_drop ()
 
std::vector< GitSubmoduleItemsubmodules ()
 
bool submodule_add (const GitCloneData &data, bool force, AbstractPtyProcess *pty)
 
bool submodule_update (const GitSubmoduleUpdateData &data, AbstractPtyProcess *pty)
 
std::string queryEntireCommitMessage (const GitHash &id)
 
std::string getDefaultBranch ()
 
void setDefaultBranch (const std::string &branchname)
 
void unsetDefaultBranch ()
 
DateTime repositoryLastModifiedTime ()
 
std::optional< std::vector< GitFileItem > > ls (std::string const &path)
 
std::optional< std::vector< char > > readfile (std::string const &path)
 

Static Public Member Functions

static GitSignatureGrade evaluateSignature (char c)
 
static bool isUncommitted (GitCommitItem const &item)
 
static GitCloneData preclone (const std::string &url, const std::string &path)
 
static std::optional< GitCommitItemparseCommit (const std::vector< char > &ba)
 

Private Member Functions

std::vector< std::string > make_branch_list_ (const std::optional< GitResult > &result)
 
std::vector< GitFileStatusstatus_s_u_ (std::string *out)
 
bool commit_ (const std::string &msg, bool amend, bool sign, AbstractPtyProcess *pty)
 
 Git ()
 
void _init (const GitContext &cx)
 
std::string submoduleURL (std::string const &path)
 

Static Private Member Functions

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

Private Attributes

std::shared_ptr< AbstractGitSessionsession_
 

Friends

class GitRunner
 

Member Typedef Documentation

◆ ReflogItemList

using Git::ReflogItemList = std::vector<GitReflogItem>

Constructor & Destructor Documentation

◆ Git() [1/3]

Git::Git ( )
private

◆ Git() [2/3]

Git::Git ( GitContext const &  cx,
std::string const &  repodir,
std::string const &  submodpath,
std::string 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()

std::vector< char > Git::blame ( const std::string &  path)
Here is the call graph for this function:

◆ branches()

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

◆ cat_file()

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

◆ checkout()

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

◆ checkout_detach()

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

◆ checkoutBranch()

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

◆ cherrypick()

void Git::cherrypick ( std::string 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 ( )

◆ clearObjectCache()

void Git::clearObjectCache ( )

◆ clone()

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

◆ commit()

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

◆ commit_()

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

◆ commit_amend_m()

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

◆ configGpgProgram()

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

◆ createBranch()

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

◆ delete_tag()

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

◆ deleteBranch()

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

◆ diff()

std::string Git::diff ( const std::string &  old_id,
const std::string &  new_id,
const GitDiffOption opt 
)
Here is the call graph for this function:

◆ diff_file()

std::string Git::diff_file ( const std::string &  old_path,
const std::string &  new_path,
const GitDiffOption opt 
)
Here is the call graph for this function:

◆ diff_full_index_head_file()

std::string Git::diff_full_index_head_file ( const std::string &  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()

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

◆ diff_to_file()

std::string Git::diff_to_file ( const std::string &  old_id,
const std::string &  path,
const GitDiffOption opt 
)
Here is the call graph for this function:

◆ errorMessage()

std::string 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 ( std::string 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()

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

◆ getCurrentBranchName()

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

◆ getDefaultBranch()

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

◆ getMessage()

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

◆ getRemotes()

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

◆ getUntrackedFiles()

std::vector< std::string > 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 ( std::string const &  arg)
inline
Here is the call graph for this function:

◆ git_nochdir()

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

◆ git_nolog()

std::optional<GitResult> Git::git_nolog ( std::string 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

◆ init()

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

◆ isUncommitted()

static bool Git::isUncommitted ( 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 ( const std::string &  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 
)
Here is the call graph for this function:

◆ log_file()

GitCommitItemList Git::log_file ( const std::string &  path,
int  maxcount 
)

コミットログを取得する

Parameters
idコミットID
maxcount最大アイテム数
Returns
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 ( std::string const &  path)

◆ ls_remote()

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

◆ make_branch_list_()

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

◆ mergeBranch()

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

◆ objectType()

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

◆ parseAheadBehind()

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

◆ parseCommit()

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

◆ parseCommitItem()

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

◆ preclone()

GitCloneData Git::preclone ( const std::string &  url,
const std::string &  path 
)
static
Here is the call graph for this function:

◆ 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,
std::string const &  remote,
std::string 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()

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

◆ quoted_text()

std::string Git::quoted_text ( std::string const &  str)
staticprivate

◆ readfile()

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

◆ rebase_abort()

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

◆ rebase_continue()

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

◆ rebase_quit()

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

◆ rebaseBranch()

void Git::rebaseBranch ( const std::string &  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 ( std::string const &  path)
inline

◆ removeRemote()

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

◆ repositoryLastModifiedTime()

DateTime 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 ( const std::string &  path)
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()

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

◆ rev_parse()

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

◆ rev_parse_show_toplevel()

std::string Git::rev_parse_show_toplevel ( )
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 ( const std::string &  path,
bool  rm_real_file 
)
Here is the call graph for this function:

◆ rm_cached()

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

◆ setDefaultBranch()

void Git::setDefaultBranch ( const std::string &  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 ( const std::string &  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 ( std::string const &  sshkey)
Here is the call graph for this function:

◆ setSubmodulePath()

void Git::setSubmodulePath ( std::string const &  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 ( std::string const &  repo,
std::string const &  sshkey 
)
Here is the call graph for this function:

◆ signingKey()

std::string 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()

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

◆ stage() [1/2]

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

◆ stage() [2/2]

bool Git::stage ( std::vector< std::string > 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()

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

◆ status_s_u()

std::vector< GitFileStatus > Git::status_s_u ( std::string *  out = nullptr)
Here is the call graph for this function:

◆ status_s_u_()

std::vector< GitFileStatus > Git::status_s_u_ ( std::string *  out)
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()

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

◆ submoduleURL()

std::string Git::submoduleURL ( std::string const &  path)
private
Here is the call graph for this function:

◆ tag()

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

◆ tags()

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

◆ toByteArray()

std::vector< char > Git::toByteArray ( 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 ( const std::string &  path)
Here is the call graph for this function:

◆ unstage() [2/2]

void Git::unstage ( std::vector< std::string > 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()

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

◆ workingDir()

std::string 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: