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  Branch
 
struct  CloneData
 
struct  CommitItem
 
class  CommitItemList
 
class  Diff
 
struct  DiffRaw
 
class  FileStatus
 
class  Hash
 
class  Hunk
 
struct  Object
 
struct  ReflogItem
 
struct  Remote
 
struct  RemoteInfo
 
struct  SubmoduleItem
 
struct  SubmoduleUpdateData
 
struct  Tag
 
struct  User
 

Public Types

enum class  SignatureGrade {
  NoSignature , Unknown , Good , Dubious ,
  Missing , Bad
}
 
enum class  FileStatusCode : unsigned int {
  Unknown , Ignored , Untracked , NotUpdated = 0x10000000 ,
  Staged_ = 0x20000000 , UpdatedInIndex , AddedToIndex , DeletedFromIndex ,
  RenamedInIndex , CopiedInIndex , Unmerged_ = 0x40000000 , Unmerged_BothDeleted ,
  Unmerged_AddedByUs , Unmerged_DeletedByThem , Unmerged_AddedByThem , Unmerged_DeletedByUs ,
  Unmerged_BothAdded , Unmerged_BothModified , Tracked_ = 0xf0000000
}
 
enum class  MergeFastForward { Default , No , Only }
 
enum class  Source { Default , Global , Local }
 
enum  SignPolicy { Unset , False , True }
 
using FileStatusList = std::vector< FileStatus >
 
using ReflogItemList = QList< ReflogItem >
 

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
 
void setCommandCache (GitCommandCache const &cc)
 
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 ()
 
CommitItemList log_all (Hash const &id, int maxcount)
 コミットログを取得する More...
 
CommitItemList log_file (QString const &path, int maxcount)
 
QStringList rev_list_all (Hash const &id, int maxcount)
 
std::optional< CommitItemlog_signature (Hash const &id)
 Git::log_signature. More...
 
CommitItemList log (int maxcount)
 
std::optional< CommitItemqueryCommitItem (const Hash &id)
 
bool clone (CloneData const &data, AbstractPtyProcess *pty)
 
FileStatusList status_s ()
 
std::optional< QByteArray > cat_file (Hash 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< Branchbranches ()
 
QString diff (QString const &old_id, QString const &new_id)
 
QString diff_file (QString const &old_path, QString const &new_path)
 
std::string diff_head (std::function< bool(std::string const &, std::string const &)> fn_accept=nullptr)
 
QList< DiffRawdiff_raw (Hash const &old_id, Hash 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 Hash &id)
 
bool push_tags (AbstractPtyProcess *pty=nullptr)
 
void remote_v (std::vector< Remote > *out)
 
void createBranch (QString const &name)
 
void checkoutBranch (QString const &name)
 
void mergeBranch (QString const &name, MergeFastForward 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
 
Hash rev_parse (QString const &name)
 
QList< Tagtags ()
 
bool tag (QString const &name, Hash const &id={})
 
bool delete_tag (QString const &name, bool remote)
 
void setRemoteURL (const Remote &remote)
 
void addRemoteURL (const Remote &remote)
 
void removeRemote (QString const &name)
 
QStringList getRemotes ()
 
User getUser (Source purpose)
 
void setUser (User 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 Hash &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 (Source purpose)
 
bool setSigningKey (QString const &id, bool global)
 
SignPolicy signPolicy (Source source)
 
bool setSignPolicy (Source source, SignPolicy policy)
 
bool configGpgProgram (QString const &path, bool global)
 
QList< RemoteInfols_remote ()
 
bool stash ()
 
bool stash_apply ()
 
bool stash_drop ()
 
QList< SubmoduleItemsubmodules ()
 
bool submodule_add (const CloneData &data, bool force, AbstractPtyProcess *pty)
 
bool submodule_update (const SubmoduleUpdateData &data, AbstractPtyProcess *pty)
 
QString queryEntireCommitMessage (const Hash &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 SignatureGrade evaluateSignature (char c)
 
static bool isUncommited (CommitItem const &item)
 
static QString trimPath (QString const &s)
 
static CloneData preclone (QString const &url, QString const &path)
 
static bool isValidID (QString const &id)
 
static bool isValidID (Hash const &id)
 
static std::optional< CommitItemparseCommit (QByteArray const &ba)
 

Private Member Functions

QStringList make_branch_list_ (const std::optional< GitResult > &result)
 
FileStatusList status_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, Branch *b)
 
static std::optional< CommitItemparseCommitItem (const QString &line)
 

Private Attributes

std::shared_ptr< AbstractGitSessionsession_
 

Friends

class GitRunner
 

Member Typedef Documentation

◆ FileStatusList

using Git::FileStatusList = std::vector<FileStatus>

◆ ReflogItemList

Member Enumeration Documentation

◆ FileStatusCode

enum Git::FileStatusCode : unsigned int
strong
Enumerator
Unknown 
Ignored 
Untracked 
NotUpdated 
Staged_ 
UpdatedInIndex 
AddedToIndex 
DeletedFromIndex 
RenamedInIndex 
CopiedInIndex 
Unmerged_ 
Unmerged_BothDeleted 
Unmerged_AddedByUs 
Unmerged_DeletedByThem 
Unmerged_AddedByThem 
Unmerged_DeletedByUs 
Unmerged_BothAdded 
Unmerged_BothModified 
Tracked_ 

◆ MergeFastForward

enum Git::MergeFastForward
strong
Enumerator
Default 
No 
Only 

◆ SignatureGrade

enum Git::SignatureGrade
strong
Enumerator
NoSignature 
Unknown 
Good 
Dubious 
Missing 
Bad 

◆ SignPolicy

Enumerator
Unset 
False 
True 

◆ Source

enum Git::Source
strong
Enumerator
Default 
Global 
Local 

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 Remote 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()

BranchList Git::branches ( )
Here is the call graph for this function:

◆ cat_file()

std::optional< QByteArray > Git::cat_file ( Hash 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 ( CloneData 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_head()

std::string Git::diff_head ( std::function< bool(std::string const &, std::string const &)>  fn_accept = nullptr)
Here is the call graph for this function:

◆ diff_raw()

QList< Git::DiffRaw > Git::diff_raw ( Hash const &  old_id,
Hash 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 SignatureGrade 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()

Git::User Git::getUser ( Source  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

◆ init()

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

◆ isUncommited()

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

◆ isValidGitCommand()

bool Git::isValidGitCommand ( ) const
inline

◆ isValidID() [1/2]

static bool Git::isValidID ( Hash const &  id)
inlinestatic

◆ isValidID() [2/2]

bool Git::isValidID ( QString const &  id)
static

◆ 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()

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

◆ log_all()

Git::CommitItemList Git::log_all ( Hash const &  id,
int  maxcount 
)

コミットログを取得する

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

◆ log_file()

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

◆ log_signature()

std::optional< Git::CommitItem > Git::log_signature ( Hash 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,
MergeFastForward  ff,
bool  squash 
)
Here is the call graph for this function:

◆ objectType()

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

◆ parseAheadBehind()

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

◆ parseCommit()

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

◆ parseCommitItem()

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

◆ preclone()

Git::CloneData 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< Git::CommitItem > Git::queryCommitItem ( const Hash id)
Here is the call graph for this function:

◆ queryEntireCommitMessage()

QString Git::queryEntireCommitMessage ( const Hash 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< Remote > *  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 ( Hash const &  id,
int  maxcount 
)
Here is the call graph for this function:

◆ rev_parse()

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

◆ revert()

bool Git::revert ( const Hash 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:

◆ setCommandCache()

void Git::setCommandCache ( GitCommandCache const &  cc)
inline

◆ setDefaultBranch()

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

◆ setRemoteURL()

void Git::setRemoteURL ( const Remote 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 ( Source  source,
SignPolicy  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 ( User 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 ( Source  purpose)
Here is the call graph for this function:

◆ signPolicy()

Git::SignPolicy Git::signPolicy ( Source  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()

Git::FileStatusList Git::status_s ( )
Here is the call graph for this function:

◆ status_s_()

Git::FileStatusList Git::status_s_ ( )
private
Here is the call graph for this function:

◆ submodule_add()

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

◆ submodule_update()

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

◆ submodules()

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

◆ tag()

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

◆ tags()

QList< Git::Tag > 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:

◆ trimPath()

QString Git::trimPath ( QString const &  s)
static

◆ 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: