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

#include <Git.h>

Inheritance diagram for Git:
Inheritance graph
[legend]
Collaboration diagram for Git:
Collaboration graph
[legend]

Classes

struct  Branch
 
struct  CloneData
 
class  CommitID
 
struct  CommitItem
 
class  CommitItemList
 
class  Context
 
class  Diff
 
struct  DiffRaw
 
class  FileStatus
 
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  SignatureGrade {
  SignatureGrade::NoSignature, SignatureGrade::Unknown, SignatureGrade::Good, SignatureGrade::Dubious,
  SignatureGrade::Missing, SignatureGrade::Bad
}
 
enum  FileStatusCode : unsigned int {
  FileStatusCode::Unknown, FileStatusCode::Ignored, FileStatusCode::Untracked, FileStatusCode::NotUpdated = 0x10000000,
  FileStatusCode::Staged_ = 0x20000000, FileStatusCode::UpdatedInIndex, FileStatusCode::AddedToIndex, FileStatusCode::DeletedFromIndex,
  FileStatusCode::RenamedInIndex, FileStatusCode::CopiedInIndex, FileStatusCode::Unmerged_ = 0x40000000, FileStatusCode::Unmerged_BothDeleted,
  FileStatusCode::Unmerged_AddedByUs, FileStatusCode::Unmerged_DeletedByThem, FileStatusCode::Unmerged_AddedByThem, FileStatusCode::Unmerged_DeletedByUs,
  FileStatusCode::Unmerged_BothAdded, FileStatusCode::Unmerged_BothModified, FileStatusCode::Tracked_ = 0xf0000000
}
 
enum  MergeFastForward { MergeFastForward::Default, MergeFastForward::No, MergeFastForward::Only }
 
enum  Source { Source::Default, Source::Global, Source::Local }
 
enum  SignPolicy { Unset, False, True }
 
using FileStatusList = std::vector< FileStatus >
 
using callback_t = bool(*)(void *, const char *, int)
 
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 () override
 
void setLogCallback (callback_t func, void *cookie)
 
QByteArray toQByteArray () const
 
void setGitCommand (QString const &gitcmd, const QString &sshcmd={})
 
QString gitCommand () const
 
void clearResult ()
 
std::string resultStdString () const
 
QString resultQString () const
 
bool chdirexec (std::function< bool()> const &fn)
 
bool git (QString const &arg, Option const &opt)
 
bool git (QString const &arg)
 
bool git_nolog (QString const &arg)
 
bool git_nochdir (QString const &arg)
 
void setWorkingRepositoryDir (QString const &repo, const QString &submodpath, const QString &sshkey)
 
QString workingDir () const
 
const QString & sshKey () const
 
void setSshKey (const QString &sshkey) const
 
QString getCurrentBranchName ()
 
bool isValidWorkingCopy () const
 
QString version ()
 
bool init ()
 
QStringList getUntrackedFiles ()
 
CommitItemList log_all (CommitID const &id, int maxcount)
 コミットログを取得する More...
 
std::optional< CommitItemlog_signature (CommitID const &id)
 Git::log_signature. More...
 
CommitItemList log (int maxcount)
 
std::optional< CommitItemqueryCommit (const CommitID &id)
 
bool clone (CloneData const &data, AbstractPtyProcess *pty)
 
FileStatusList status_s ()
 
std::optional< QByteArray > cat_file (const CommitID &id)
 
void resetFile (QString const &path)
 
void resetAllFiles ()
 
void removeFile (QString const &path)
 
void add_A ()
 
void unstage_all ()
 
void stage (QString const &path)
 
void stage (QStringList const &paths)
 
void unstage (QString const &path)
 
void unstage (QStringList const &paths)
 
void pull (AbstractPtyProcess *pty=nullptr)
 
void fetch (AbstractPtyProcess *pty=nullptr, bool prune=false)
 
void 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)
 
QList< DiffRawdiff_raw (CommitID const &old_id, CommitID 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 CommitID &id)
 
bool push_tags (AbstractPtyProcess *pty=nullptr)
 
void getRemoteURLs (QList< Remote > *out)
 
void createBranch (QString const &name)
 
void checkoutBranch (QString const &name)
 
void mergeBranch (QString const &name, MergeFastForward ff, bool squash)
 
void rebaseBranch (QString const &name)
 
QString diff_to_file (QString const &old_id, QString const &path)
 
QString errorMessage () const
 
GitPtr dup () const
 
CommitID rev_parse (QString const &name)
 
QList< Tagtags ()
 
QList< Tagtags2 ()
 
bool tag (QString const &name, const CommitID &id=QString())
 
void 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 ()
 
void push_u (bool set_upstream, QString const &remote, QString const &branch, bool force, AbstractPtyProcess *pty)
 
QString objectType (const CommitID &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)
 

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 (CommitID const &id)
 
static bool isValidWorkingCopy (QString const &dir)
 
static CommitItem parseCommit (const QByteArray &ba)
 

Private Member Functions

QStringList make_branch_list_ ()
 
QByteArray cat_file_ (const CommitID &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
 

Member Typedef Documentation

◆ callback_t

using Git::callback_t = bool (*)(void *, const char *, int)

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

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

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

◆ cat_file()

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

◆ cat_file_()

QByteArray Git::cat_file_ ( const CommitID 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:

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

void Git::delete_tag ( QString const &  name,
bool  remote 
)
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_raw()

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

◆ dup()

GitPtr Git::dup ( ) const
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()

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

◆ fetch_tags_f()

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

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

◆ getRemoteURLs()

void Git::getRemoteURLs ( QList< Remote > *  out)
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 
)
Here is the call graph for this function:

◆ git_nochdir()

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

◆ git_nolog()

bool Git::git_nolog ( QString const &  arg)
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 ( CommitID 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 ( CommitID const &  id,
int  maxcount 
)

コミットログを取得する

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

◆ log_signature()

std::optional< Git::CommitItem > Git::log_signature ( CommitID 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 CommitID id)
Here is the call graph for this function:

◆ parseAheadBehind()

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

◆ parseCommit()

Git::CommitItem Git::parseCommit ( const QByteArray &  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()

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

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

◆ queryCommit()

std::optional< Git::CommitItem > Git::queryCommit ( const CommitID id)
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:

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

◆ 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 Git::resultStdString ( ) const

◆ rev_parse()

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

◆ revert()

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

◆ setGitCommand()

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

◆ setLogCallback()

void Git::setLogCallback ( callback_t  func,
void *  cookie 
)

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

const QString & Git::sshKey ( ) const

◆ stage() [1/2]

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

◆ stage() [2/2]

void Git::stage ( QStringList const &  paths)
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,
const CommitID id = QString() 
)
Here is the call graph for this function:

◆ tags()

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

◆ tags2()

QList< Git::Tag > Git::tags2 ( )
Here is the call graph for this function:

◆ toQByteArray()

QByteArray Git::toQByteArray ( ) const

◆ trimPath()

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

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

void 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

Member Data Documentation

◆ m

Private* Git::m
private

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