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>

Collaboration diagram for Git:
Collaboration graph
[legend]

Classes

struct  Branch
 
struct  CloneData
 
class  CommandCache
 
struct  CommitItem
 
class  CommitItemList
 
class  Context
 
class  Diff
 
struct  DiffRaw
 
class  FileStatus
 
class  Hash
 
class  Hunk
 
struct  Object
 
struct  Option
 
struct  Private
 
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 (Context const &cx, QString const &repodir, QString const &submodpath, QString const &sshkey)
 
 Git (Git &&r)=delete
 
 ~Git ()
 
void setCommandCache (CommandCache const &cc)
 
QByteArray toQByteArray () const
 
void setGitCommand (QString const &gitcmd, const QString &sshcmd={})
 
QString gitCommand () const
 
void clearResult ()
 
std::string_view resultStdString () const
 
QString resultQString () const
 
bool chdirexec (std::function< bool()> const &fn)
 
bool git (QString const &arg, Option const &opt, bool debug_=false)
 
bool git (QString const &arg)
 
bool git_nolog (QString const &arg, AbstractPtyProcess *pty)
 
bool git_nochdir (QString const &arg, AbstractPtyProcess *pty)
 
void setWorkingRepositoryDir (QString const &repo, const QString &submodpath, const QString &sshkey)
 
QString workingDir () const
 
QString const & sshKey () const
 
void setSshKey (const QString &sshkey) const
 
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 removeFile (QString const &path)
 
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)
 
bool fetch_tags_f (AbstractPtyProcess *pty)
 
QList< Branchbranches ()
 
int getProcessExitCode () const
 
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 ()
 
QString diff_to_file (QString const &old_id, QString const &path)
 
QString errorMessage () 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 ()
 

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 bool isValidWorkingCopy (QString const &dir)
 
static std::optional< CommitItemparseCommit (QByteArray const &ba)
 

Private Member Functions

QStringList make_branch_list_ ()
 
QByteArray cat_file_ (Hash const &id)
 
FileStatusList status_s_ ()
 
bool commit_ (QString const &msg, bool amend, bool sign, AbstractPtyProcess *pty)
 
 Git ()
 
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

Privatem
 

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

Member Function Documentation

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

◆ cat_file_()

QByteArray Git::cat_file_ ( Hash const &  id)
private
Here is the call graph for this function:

◆ chdirexec()

bool Git::chdirexec ( std::function< bool()> const &  fn)
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:

◆ clearResult()

void Git::clearResult ( )

◆ 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

◆ evaluateSignature()

static SignatureGrade Git::evaluateSignature ( char  c)
inlinestatic

◆ fetch()

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

◆ fetch_tags_f()

bool Git::fetch_tags_f ( AbstractPtyProcess pty)
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:

◆ getProcessExitCode()

int Git::getProcessExitCode ( ) const

◆ 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() [1/2]

bool Git::git ( QString const &  arg)
inline
Here is the call graph for this function:

◆ git() [2/2]

bool Git::git ( QString const &  arg,
Option const &  opt,
bool  debug_ = false 
)
Here is the call graph for this function:

◆ git_nochdir()

bool Git::git_nochdir ( QString const &  arg,
AbstractPtyProcess pty 
)
inline
Here is the call graph for this function:

◆ git_nolog()

bool Git::git_nolog ( QString const &  arg,
AbstractPtyProcess pty 
)
inline
Here is the call graph for this function:

◆ gitCommand()

QString Git::gitCommand ( ) const

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

◆ 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)
static
Here is the call graph for this function:

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

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

◆ make_branch_list_()

QStringList Git::make_branch_list_ ( )
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:

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

◆ removeFile()

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

◆ 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
Here is the call graph for this function:

◆ resultStdString()

std::string_view Git::resultStdString ( ) const

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

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

◆ setCommandCache()

void Git::setCommandCache ( CommandCache const &  cc)

◆ setDefaultBranch()

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

◆ setGitCommand()

void Git::setGitCommand ( QString const &  gitcmd,
const QString &  sshcmd = {} 
)

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

◆ 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 &  submodpath,
const QString &  sshkey 
)

◆ 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

◆ 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

◆ 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

Friends And Related Function Documentation

◆ GitRunner

friend class GitRunner
friend

Member Data Documentation

◆ m

Private* Git::m
private

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