Guitar
Git.h
Go to the documentation of this file.
1 #ifndef GIT_H
2 #define GIT_H
3 
4 #include "GitBasicSession.h"
5 #include "GitTypes.h"
6 #include "common/misc.h"
7 #include <QDateTime>
8 #include <zlib.h>
9 
10 #define GIT_ID_LENGTH (40)
11 #define PATH_PREFIX "*"
12 
13 enum class LineSide {
14  Left,
15  Right,
16 };
17 
18 struct TreeLine {
19  int index;
20  int depth;
21  int color_number = 0;
22  bool bend_early = false;
23  TreeLine(int index = -1, int depth = -1)
24  : index(index)
25  , depth(depth)
26  {
27  }
28 };
29 
30 class GitContext {
31 public:
32  QString git_command;
33  QString ssh_command;
34 
35  std::shared_ptr<AbstractGitSession> connect() const;
36 };
37 
38 class Git {
39  friend class GitRunner;
40 private:
41  std::shared_ptr<AbstractGitSession> session_;
42 public:
43  class Hash {
44  private:
45  bool valid_ = false;
46  uint8_t id_[GIT_ID_LENGTH / 2];
47  template <typename VIEW> void _assign(VIEW const &id);
48  public:
49  Hash() {}
50  explicit Hash(std::string_view const &id);
51  explicit Hash(QString const &id);
52  explicit Hash(char const *id);
53  void assign(std::string_view const &qid);
54  void assign(const QString &qid);
55  QString toQString(int maxlen = -1) const;
56  bool isValid() const;
57  int compare(Hash const &other) const
58  {
59  if (!valid_ && other.valid_) return -1;
60  if (valid_ && !other.valid_) return 1;
61  if (!valid_ && !other.valid_) return 0;
62  return memcmp(id_, other.id_, sizeof(id_));
63  }
64  operator bool () const
65  {
66  return isValid();
67  }
68  size_t _std_hash() const
69  {
70  return crc32(0, id_, sizeof(id_));
71  }
72  };
73 
74  struct Object {
75  enum class Type { // 値は固定。packフォーマットで決まってる
76  NONE = -1,
77  UNKNOWN = 0,
78  COMMIT = 1,
79  TREE = 2,
80  BLOB = 3,
81  TAG = 4,
82  UNDEFINED = 5,
83  OFS_DELTA = 6,
84  REF_DELTA = 7,
85  };
87  QByteArray content;
88  operator bool () const
89  {
90  return type != Type::NONE;
91  }
92  };
93 
94  struct SubmoduleItem {
95  QString name;
97  QString path;
98  QString refs;
99  QString url;
100  operator bool () const
101  {
102  return isValidID(id) && !path.isEmpty();
103  }
104  };
105 
106  enum class SignatureGrade {
107  NoSignature,
108  Unknown,
109  Good,
110  Dubious,
111  Missing,
112  Bad,
113  };
114 
115  struct CommitItem {
118  QList<Hash> parent_ids;
119  QString author;
120  QString email;
121  QString message;
122  QDateTime commit_date;
123  std::vector<TreeLine> parent_lines;
124  bool has_gpgsig = false;
125  QString gpgsig;
126  struct {
127  QString text;
128  char verify = 0; // git log format:%G?
129  std::vector<uint8_t> key_fingerprint;
130  QString trust;
131  } sign;
132  bool has_child = false;
133  int marker_depth = -1;
134  bool resolved = false;
135  bool order_fixed = false; // 時差や時計の誤差などの影響により、並び順の調整が行われたとき
136  void setParents(QStringList const &list);
137  operator bool () const
138  {
139  return commit_id;
140  }
141  };
142 
144  public:
145  std::vector<CommitItem> list;
146  std::map<Hash, size_t> index;
147  size_t size() const
148  {
149  return list.size();
150  }
151  void resize(size_t n)
152  {
153  list.resize(n);
154  }
155  CommitItem &at(size_t i)
156  {
157  return list[i];
158  }
159  CommitItem const &at(size_t i) const
160  {
161  return list.at(i);
162  }
164  {
165  return at(i);
166  }
167  CommitItem const &operator [] (size_t i) const
168  {
169  return at(i);
170  }
171  void clear()
172  {
173  list.clear();
174  }
175  bool empty() const
176  {
177  return list.empty();
178  }
179  void updateIndex()
180  {
181  index.clear();
182  for (size_t i = 0; i < list.size(); i++) {
183  index[list[i].commit_id] = i;
184  }
185  }
186  CommitItem *find(Hash const &id)
187  {
188  auto it = index.find(id);
189  if (it != index.end()) {
190  return &list[it->second];
191  }
192  return nullptr;
193  }
194  CommitItem const *find(Hash const &id) const
195  {
196  return const_cast<CommitItemList *>(this)->find(id);
197  }
198  };
199 
200  class Hunk {
201  public:
202  std::string at;
203  std::vector<std::string> lines;
204  };
205  class Diff {
206  public:
207  enum class Type {
208  Unknown,
209  Modify,
210  Copy,
211  Rename,
212  Create,
213  Delete,
214  ChType,
215  Unmerged,
216  };
218  QString diff;
219  QString index;
220  QString path;
221  QString mode;
222  struct BLOB_AB_ {
223  QString a_id_or_path; // コミットIDまたはファイルパス。パスのときは PATH_PREFIX('*')で始まる
224  QString b_id_or_path;
225  } blob;
226  QList<Hunk> hunks;
231  Diff() = default;
232  Diff(QString const &id, QString const &path, QString const &mode)
233  {
234  makeForSingleFile(this, QString(GIT_ID_LENGTH, '0'), id, path, mode);
235  }
236  bool isSubmodule() const
237  {
238  return mode == "160000";
239  }
240  private:
241  void makeForSingleFile(Diff *diff, QString const &id_a, QString const &id_b, QString const &path, QString const &mode);
242  };
243 
245  {
246  switch (c) {
247  case 'G':
248  return SignatureGrade::Good;
249  case 'U':
250  case 'X':
251  case 'Y':
253  case 'B':
254  case 'R':
255  return SignatureGrade::Bad;
256  case 'E':
258  case 'N':
259  case ' ':
260  case 0:
262  }
264  }
265 
266  static bool isUncommited(CommitItem const &item)
267  {
268  return !item.commit_id.isValid();
269  }
270 
271  struct Branch {
272  QString name;
274  QString remote;
275  int ahead = 0;
276  int behind = 0;
277  enum {
279  Current = 0x0001,
280  HeadDetachedAt = 0x0002,
282  };
283  int flags = 0;
284  operator bool () const
285  {
286  return id.isValid() && !name.isEmpty();
287  }
288  bool isCurrent() const
289  {
290  return flags & Current;
291  }
292  bool isHeadDetached() const
293  {
294  return flags & HeadDetachedAt;
295  }
296  };
297 
298  struct Tag {
299  QString name;
301  };
302 
303  enum class FileStatusCode : unsigned int {
304  Unknown,
305  Ignored,
306  Untracked,
307  NotUpdated = 0x10000000,
308  Staged_ = 0x20000000,
310  AddedToIndex,
314  Unmerged_ = 0x40000000,
322  Tracked_ = 0xf0000000
323  };
324 
325  enum class MergeFastForward {
326  Default,
327  No,
328  Only,
329  };
330 
331  class FileStatus {
332  public:
333  struct Data {
334  char code_x = 0;
335  char code_y = 0;
337  QString rawpath1;
338  QString rawpath2;
339  QString path1;
340  QString path2;
341  } data;
342 
343  static FileStatusCode parseFileStatusCode(char x, char y);
344 
345  bool isStaged() const
346  {
347  return (int)data.code & (int)FileStatusCode::Staged_;
348  }
349 
350  bool isUnmerged() const
351  {
352  return (int)data.code & (int)FileStatusCode::Unmerged_;
353  }
354 
355  bool isTracked() const
356  {
357  return (int)data.code & (int)FileStatusCode::Tracked_;
358  }
359 
360  void parse(QString const &text);
361 
362  FileStatus() = default;
363 
364  FileStatus(QString const &text)
365  {
366  parse(text);
367  }
368 
370  {
371  return data.code;
372  }
373 
374  int code_x() const
375  {
376  return data.code_x;
377  }
378 
379  int code_y() const
380  {
381  return data.code_y;
382  }
383 
384  bool isDeleted() const
385  {
386  return code_x() == 'D' || code_y() == 'D';
387  }
388 
389  QString path1() const
390  {
391  return data.path1;
392  }
393 
394  QString path2() const
395  {
396  return data.path2;
397  }
398 
399  QString rawpath1() const
400  {
401  return data.rawpath1;
402  }
403 
404  QString rawpath2() const
405  {
406  return data.rawpath2;
407  }
408  };
409  using FileStatusList = std::vector<FileStatus>;
410 
411  static QString trimPath(QString const &s);
412 
413 private:
414  QStringList make_branch_list_(const std::optional<GitResult> &result);
416  bool commit_(QString const &msg, bool amend, bool sign, AbstractPtyProcess *pty);
417  static void parseAheadBehind(QString const &s, Branch *b);
418  Git();
419  void _init(const GitContext &cx);
420  QString encodeQuotedText(QString const &str);
421  static std::optional<CommitItem> parseCommitItem(const QString &line);
422 public:
423  Git(GitContext const &cx, QString const &repodir, QString const &submodpath, QString const &sshkey);
424  Git(Git &&r) = delete;
425  ~Git() = default;
426 
427  void clearCommandCache();
428 
430  {
431  return session_->gitinfo();
432  }
434  {
435  return session_->gitinfo();
436  }
437 
438  // AbstractGitSession::Var const &var() const
439  // {
440  // return session_->var();
441  // }
442 
444  {
445  session_->set_command_cache(cc);
446  }
447 
448  QByteArray toQByteArray(const std::optional<GitResult> &var) const;
449  bool isValidGitCommand() const
450  {
451  return session_->is_connected();
452  }
453  std::string resultStdString(const std::optional<GitResult> &var) const;
454  QString resultQString(const std::optional<GitResult> &var) const;
455  std::optional<GitResult> exec_git(QString const &arg, AbstractGitSession::Option const &opt)
456  {
457  return session_->exec_git(arg, opt);
458  }
459  std::optional<GitResult> git(QString const &arg)
460  {
461  return exec_git(arg, {});
462  }
463  std::optional<GitResult> git_nolog(QString const &arg, AbstractPtyProcess *pty)
464  {
466  opt.pty = pty;
467  opt.log = false;
468  return exec_git(arg, opt);
469  }
470  std::optional<GitResult> git_nochdir(QString const &arg, AbstractPtyProcess *pty)
471  {
473  opt.pty = pty;
474  opt.chdir = false;
475  return exec_git(arg, opt);
476  }
477  bool remove(QString const &path)
478  {
479  return session_->remove(path);
480  }
481 
482  void setWorkingRepositoryDir(QString const &repo, const QString &sshkey);
483  void setSubmodulePath(const QString &submodpath);
484 
485  QString workingDir() const
486  {
487  return session_->workingDir();
488  }
489  QString const &sshKey() const;
490  void setSshKey(const QString &sshkey);
491 
492  QString getCurrentBranchName();
493  bool isValidWorkingCopy() const;
494  QString version();
495  bool init();
496  QStringList getUntrackedFiles();
497 
498  CommitItemList log_all(Hash const &id, int maxcount);
499  CommitItemList log_file(QString const &path, int maxcount);
500  QStringList rev_list_all(Hash const &id, int maxcount);
501 
502  std::optional<CommitItem> log_signature(Hash const &id);
503  CommitItemList log(int maxcount);
504  std::optional<CommitItem> queryCommitItem(const Hash &id);
505 
506  struct CloneData {
507  QString url;
508  QString basedir;
509  QString subdir;
510  };
511  static CloneData preclone(QString const &url, QString const &path);
512  bool clone(CloneData const &data, AbstractPtyProcess *pty);
513 
515  std::optional<QByteArray> cat_file(Hash const &id);
516  void resetFile(QString const &path);
517  void resetAllFiles();
518 
519  void rm(QString const &path, bool rm_real_file);
520 
521  void add_A();
522  bool unstage_all();
523 
524  void stage(QString const &path);
525  bool stage(QStringList const &paths, AbstractPtyProcess *pty);
526  void unstage(QString const &path);
527  void unstage(QStringList const &paths);
528  bool pull(AbstractPtyProcess *pty = nullptr);
529 
530  bool fetch(AbstractPtyProcess *pty = nullptr, bool prune = false);
531 
532  QList<Branch> branches();
533 
534  // int getProcessExitCode(const std::optional<GitResult> &var) const;
535 
536  QString diff(QString const &old_id, QString const &new_id);
537  QString diff_file(QString const &old_path, QString const &new_path);
538 
539  std::string diff_head(std::function<bool (std::string const &, std::string const &)> fn_accept = nullptr);
540 
541  struct DiffRaw {
542  struct AB {
543  QString id;
544  QString mode;
545  } a, b;
546  QString state;
547  QStringList files;
548  };
549 
550  struct Remote {
551  QString name;
552  QString url_fetch;
553  QString url_push;
554  QString ssh_key;
555  bool operator < (Remote const &r) const
556  {
557  return name < r.name;
558  }
559  QString const &url() const
560  {
561  return url_fetch;
562  }
563  void set_url(QString const &url)
564  {
565  url_fetch = url;
566  url_push = url;
567  }
568  };
569 
570  QList<DiffRaw> diff_raw(Hash const &old_id, Hash const &new_id);
571 
572  static bool isValidID(QString const &id);
573  static bool isValidID(Hash const &id)
574  {
575  return id.isValid();
576  }
577 
578  QString status();
579  bool commit(QString const &text, bool sign, AbstractPtyProcess *pty);
580  bool commit_amend_m(QString const &text, bool sign, AbstractPtyProcess *pty);
581  bool revert(const Hash &id);
582  bool push_tags(AbstractPtyProcess *pty = nullptr);
583  void remote_v(std::vector<Remote> *out);
584  void createBranch(QString const &name);
585  void checkoutBranch(QString const &name);
586  void mergeBranch(QString const &name, MergeFastForward ff, bool squash);
587  bool deleteBranch(QString const &name);
588 
589  bool checkout(QString const &branch_name, QString const &id = {});
590  bool checkout_detach(QString const &id);
591 
592  void rebaseBranch(QString const &name);
593  void rebase_abort();
594 
595  bool isValidWorkingCopy(QString const &dir) const;
596  QString diff_to_file(QString const &old_id, QString const &path);
597  QString errorMessage(const std::optional<GitResult> &var) const;
598 
599  Hash rev_parse(QString const &name);
600  QList<Tag> tags();
601  bool tag(QString const &name, Hash const &id = {});
602  bool delete_tag(QString const &name, bool remote);
603  void setRemoteURL(const Remote &remote);
604  void addRemoteURL(const Remote &remote);
605  void removeRemote(QString const &name);
606  QStringList getRemotes();
607 
608  struct User {
609  QString name;
610  QString email;
611  operator bool () const
612  {
614  }
615  };
616  enum class Source {
617  Default,
618  Global,
619  Local,
620  };
621 
622  User getUser(Source purpose);
623  void setUser(User const&user, bool global);
624 
625  bool reset_head1();
626  bool reset_hard();
627  bool clean_df();
628  bool push_u(bool set_upstream, QString const &remote, QString const &branch, bool force, AbstractPtyProcess *pty);
629  QString objectType(const Hash &id);
630  bool rm_cached(QString const &file);
631  void cherrypick(QString const &name);
632  QString getCherryPicking() const;
633 
634  QString getMessage(const QString &id);
635 
636  struct ReflogItem {
637  QString id;
638  QString head;
639  QString command;
640  QString message;
641  struct File {
642  QString atts_a;
643  QString atts_b;
644  QString id_a;
645  QString id_b;
646  QString type;
647  QString path;
648  };
649  QList<File> files;
650  };
651  using ReflogItemList = QList<ReflogItem>;
652 
653  bool reflog(ReflogItemList *out, int maxcount = 100);
654  QByteArray blame(QString const &path);
655 
656  enum SignPolicy {
660  };
661  QString signingKey(Source purpose);
662  bool setSigningKey(QString const &id, bool global);
663  SignPolicy signPolicy(Source source);
664  bool setSignPolicy(Source source, SignPolicy policy);
665  bool configGpgProgram(QString const &path, bool global);
666 
667  struct RemoteInfo {
668  QString commit_id;
669  QString name;
670  };
671  QList<RemoteInfo> ls_remote();
672 
673  bool stash();
674  bool stash_apply();
675  bool stash_drop();
676 
678  bool init = true;
679  bool recursive = true;
680  };
681 
682 
683  QList<SubmoduleItem> submodules();
684  bool submodule_add(const CloneData &data, bool force, AbstractPtyProcess *pty);
686  static std::optional<CommitItem> parseCommit(QByteArray const &ba);
687  QString queryEntireCommitMessage(const Hash &id);
688 
689  QString getDefaultBranch();
690  void setDefaultBranch(QString const &branchname);
691  void unsetDefaultBranch();
692  QDateTime repositoryLastModifiedTime();
693 
694  std::optional<std::vector<GitFileItem>> ls(const QString &path);
695  std::optional<std::vector<char>> readfile(const QString &path);
696 };
697 
699  enum class Type {
700  None,
701  BranchLocal,
702  BranchRemote,
703  Tag,
704  };
706  QString remote;
707  QString name;
709 };
710 using NamedCommitList = QList<NamedCommitItem>;
711 
712 void parseDiff(const std::string_view &s, Git::Diff const *info, Git::Diff *out);
713 
714 void parseGitSubModules(QByteArray const &ba, QList<Git::SubmoduleItem> *out);
715 
716 static inline bool operator == (Git::Hash const &l, Git::Hash const &r)
717 {
718  return l.compare(r) == 0;
719 }
720 
721 static inline bool operator < (Git::Hash const &l, Git::Hash const &r)
722 {
723  return l.compare(r) < 0;
724 }
725 
726 namespace std {
727 template <> class hash<Git::Hash> {
728 public:
729  size_t operator () (Git::Hash const &h) const
730  {
731  return h._std_hash();
732  }
733 };
734 }
735 
736 using GitPtr = std::shared_ptr<Git>;
737 
738 // GitRunner
739 
740 class GitRunner {
741 public:
743  GitRunner() = default;
745  : git(git)
746  {
747  }
748  GitRunner(GitRunner const &that)
749  : git(that.git)
750  {
751  }
753  : git(std::move(that.git))
754  {
755  }
756  void operator = (GitRunner const &that)
757  {
758  git = that.git;
759  }
760  operator bool () const
761  {
762  return (bool)git;
763  }
764  GitRunner dup() const;
765 
767  {
768  if (git) git->clearCommandCache();
769  }
770 
771  static std::optional<Git::CommitItem> parseCommit(QByteArray const &ba)
772  {
773  return Git::parseCommit(ba);
774  }
775 
776  bool isValidWorkingCopy(QString const &dir) const
777  {
778  return git && git->isValidWorkingCopy(dir);
779  }
780 
781  bool isValidWorkingCopy() const
782  {
783  return git && git->isValidWorkingCopy();
784  }
785 
786  void setWorkingRepositoryDir(QString const &repo, const QString &sshkey)
787  {
788  Q_ASSERT(git);
789  git->setWorkingRepositoryDir(repo, sshkey);
790  }
791  void setSubmodulePath(const QString &submodpath)
792  {
793  Q_ASSERT(git);
794  git->setSubmodulePath(submodpath);
795  }
796  QString workingDir() const
797  {
798  Q_ASSERT(git);
799  return git->workingDir();
800  }
801  QString const &sshKey() const
802  {
803  Q_ASSERT(git);
804  return git->sshKey();
805  }
806  void setSshKey(const QString &sshkey) const
807  {
808  Q_ASSERT(git);
809  git->setSshKey(sshkey);
810  }
811 
812  QString getMessage(const QString &id)
813  {
814  Q_ASSERT(git);
815  return git->getMessage(id);
816  }
817  QString errorMessage(std::optional<GitResult> const &var) const
818  {
819  Q_ASSERT(git);
820  return git->errorMessage(var);
821  }
822 
823  bool remove(QString const &path)
824  {
825  Q_ASSERT(git);
826  return git->remove(path);
827  }
828 
829  Git::Hash rev_parse(QString const &name)
830  {
831  Q_ASSERT(git);
832  return git->rev_parse(name);
833  }
834  void setRemoteURL(const Git::Remote &remote)
835  {
836  Q_ASSERT(git);
837  git->setRemoteURL(remote);
838  }
839  void addRemoteURL(const Git::Remote &remote)
840  {
841  Q_ASSERT(git);
842  git->addRemoteURL(remote);
843  }
844  void removeRemote(QString const &name)
845  {
846  Q_ASSERT(git);
847  git->removeRemote(name);
848  }
849  QStringList getRemotes()
850  {
851  Q_ASSERT(git);
852  return git->getRemotes();
853  }
854 
855  QString version()
856  {
857  Q_ASSERT(git);
858  return git->version();
859  }
860 
861  bool init()
862  {
863  Q_ASSERT(git);
864  return git->init();
865  }
866 
867  QList<Git::Tag> tags()
868  {
869  Q_ASSERT(git);
870  return git->tags();
871  }
872  bool tag(QString const &name, Git::Hash const &id = {})
873  {
874  Q_ASSERT(git);
875  return git->tag(name, id);
876  }
877  bool delete_tag(QString const &name, bool remote)
878  {
879  Q_ASSERT(git);
880  return git->delete_tag(name, remote);
881  }
882 
883  void resetFile(QString const &path)
884  {
885  Q_ASSERT(git);
886  git->resetFile(path);
887  }
889  {
890  Q_ASSERT(git);
891  git->resetAllFiles();
892  }
893 
894  void removeFile(QString const &path, bool rm_real_file)
895  {
896  Q_ASSERT(git);
897  git->rm(path, rm_real_file);
898  }
899 
901  {
902  Q_ASSERT(git);
903  return git->getUser(purpose);
904  }
905  void setUser(Git::User const&user, bool global)
906  {
907  Q_ASSERT(git);
908  git->setUser(user, global);
909  }
911  {
912  Q_ASSERT(git);
913  return git->getDefaultBranch();
914  }
915  void setDefaultBranch(QString const &branchname)
916  {
917  Q_ASSERT(git);
918  git->setDefaultBranch(branchname);
919  }
921  {
922  Q_ASSERT(git);
923  git->unsetDefaultBranch();
924  }
926  {
927  Q_ASSERT(git);
928  return git->repositoryLastModifiedTime();
929  }
930  QString status()
931  {
932  Q_ASSERT(git);
933  return git->status();
934  }
935  bool commit(QString const &text, bool sign, AbstractPtyProcess *pty)
936  {
937  Q_ASSERT(git);
938  return git->commit(text, sign, pty);
939  }
940  bool commit_amend_m(QString const &text, bool sign, AbstractPtyProcess *pty)
941  {
942  Q_ASSERT(git);
943  return git->commit_amend_m(text, sign, pty);
944  }
945  bool revert(const Git::Hash &id)
946  {
947  Q_ASSERT(git);
948  return git->revert(id);
949  }
950  bool push_tags(AbstractPtyProcess *pty = nullptr)
951  {
952  Q_ASSERT(git);
953  return git->push_tags(pty);
954  }
955  void remote_v(std::vector<Git::Remote> *out)
956  {
957  Q_ASSERT(git);
958  git->remote_v(out);
959  }
960  void createBranch(QString const &name)
961  {
962  Q_ASSERT(git);
963  git->createBranch(name);
964  }
965  void checkoutBranch(QString const &name)
966  {
967  Q_ASSERT(git);
968  git->checkoutBranch(name);
969  }
970  void mergeBranch(QString const &name, Git::MergeFastForward ff, bool squash)
971  {
972  Q_ASSERT(git);
973  git->mergeBranch(name, ff, squash);
974  }
975  bool deleteBranch(QString const &name)
976  {
977  Q_ASSERT(git);
978  return git->deleteBranch(name);
979  }
980 
981  bool checkout(QString const &branch_name, QString const &id = {})
982  {
983  Q_ASSERT(git);
984  return git->checkout(branch_name, id);
985  }
986  bool checkout_detach(QString const &id)
987  {
988  Q_ASSERT(git);
989  return git->checkout_detach(id);
990  }
991 
992  void rebaseBranch(QString const &name)
993  {
994  Q_ASSERT(git);
995  git->rebaseBranch(name);
996  }
998  {
999  Q_ASSERT(git);
1000  git->rebase_abort();
1001  }
1002 
1003  Git::CommitItemList log_all(Git::Hash const &id, int maxcount)
1004  {
1005  Q_ASSERT(git);
1006  return git->log_all(id, maxcount);
1007  }
1008  Git::CommitItemList log_file(QString const &path, int maxcount)
1009  {
1010  Q_ASSERT(git);
1011  return git->log_file(path, maxcount);
1012  }
1013  QStringList rev_list_all(Git::Hash const &id, int maxcount)
1014  {
1015  Q_ASSERT(git);
1016  return git->rev_list_all(id, maxcount);
1017  }
1018 
1019  std::optional<Git::CommitItem> log_signature(Git::Hash const &id)
1020  {
1021  Q_ASSERT(git);
1022  return git->log_signature(id);
1023  }
1024  Git::CommitItemList log(int maxcount)
1025  {
1026  Q_ASSERT(git);
1027  return git->log(maxcount);
1028  }
1029  std::optional<Git::CommitItem> queryCommitItem(const Git::Hash &id)
1030  {
1031  Q_ASSERT(git);
1032  return git->queryCommitItem(id);
1033  }
1034 
1035  bool stash()
1036  {
1037  Q_ASSERT(git);
1038  return git->stash();
1039  }
1041  {
1042  Q_ASSERT(git);
1043  return git->stash_apply();
1044  }
1045  bool stash_drop()
1046  {
1047  Q_ASSERT(git);
1048  return git->stash_drop();
1049  }
1050 
1051  QList<Git::SubmoduleItem> submodules()
1052  {
1053  Q_ASSERT(git);
1054  return git->submodules();
1055  }
1056  bool submodule_add(const Git::CloneData &data, bool force, AbstractPtyProcess *pty)
1057  {
1058  Q_ASSERT(git);
1059  return git->submodule_add(data, force, pty);
1060  }
1062  {
1063  Q_ASSERT(git);
1064  return git->submodule_update(data, pty);
1065  }
1067  {
1068  Q_ASSERT(git);
1069  return git->queryEntireCommitMessage(id);
1070  }
1071 
1072  QList<Git::DiffRaw> diff_raw(Git::Hash const &old_id, Git::Hash const &new_id)
1073  {
1074  Q_ASSERT(git);
1075  return git->diff_raw(old_id, new_id);
1076  }
1077  std::string diff_head(std::function<bool (std::string const &name, std::string const &mime)> fn_accept = nullptr)
1078  {
1079  Q_ASSERT(git);
1080  return git->diff_head(fn_accept);
1081  }
1082  QString diff(QString const &old_id, QString const &new_id)
1083  {
1084  Q_ASSERT(git);
1085  return git->diff(old_id, new_id);
1086  }
1087  QString diff_file(QString const &old_path, QString const &new_path)
1088  {
1089  Q_ASSERT(git);
1090  return git->diff_file(old_path, new_path);
1091  }
1092  QString diff_to_file(QString const &old_id, QString const &path)
1093  {
1094  Q_ASSERT(git);
1095  return git->diff_to_file(old_id, path);
1096  }
1097 
1099  {
1100  Q_ASSERT(git);
1101  return git->status_s();
1102  }
1103  std::optional<QByteArray> cat_file(const Git::Hash &id)
1104  {
1105  Q_ASSERT(git);
1106  return git->cat_file(id);
1107  }
1108  bool clone(Git::CloneData const &data, AbstractPtyProcess *pty)
1109  {
1110  Q_ASSERT(git);
1111  return git->clone(data, pty);
1112  }
1113  void add_A()
1114  {
1115  Q_ASSERT(git);
1116  git->add_A();
1117  }
1119  {
1120  Q_ASSERT(git);
1121  return git->unstage_all();
1122  }
1123 
1124  void stage(QString const &path)
1125  {
1126  Q_ASSERT(git);
1127  git->stage(path);
1128  }
1129  bool stage(QStringList const &paths, AbstractPtyProcess *pty)
1130  {
1131  Q_ASSERT(git);
1132  return git->stage(paths, pty);
1133  }
1134  void unstage(QString const &path)
1135  {
1136  Q_ASSERT(git);
1137  git->unstage(path);
1138  }
1139  void unstage(QStringList const &paths)
1140  {
1141  Q_ASSERT(git);
1142  git->unstage(paths);
1143  }
1144  bool pull(AbstractPtyProcess *pty = nullptr)
1145  {
1146  Q_ASSERT(git);
1147  return git->pull(pty);
1148  }
1149 
1150  bool fetch(AbstractPtyProcess *pty = nullptr, bool prune = false)
1151  {
1152  Q_ASSERT(git);
1153  return git->fetch(pty, prune);
1154  }
1156  {
1157  Q_ASSERT(git);
1158  return git->reset_head1();
1159  }
1160  bool reset_hard()
1161  {
1162  Q_ASSERT(git);
1163  return git->reset_hard();
1164  }
1165  bool clean_df()
1166  {
1167  Q_ASSERT(git);
1168  return git->clean_df();
1169  }
1170  bool push_u(bool set_upstream, QString const &remote, QString const &branch, bool force, AbstractPtyProcess *pty)
1171  {
1172  Q_ASSERT(git);
1173  return git->push_u(set_upstream, remote, branch, force, pty);
1174  }
1175  QString objectType(const Git::Hash &id)
1176  {
1177  Q_ASSERT(git);
1178  return git->objectType(id);
1179  }
1180  bool rm_cached(QString const &file)
1181  {
1182  Q_ASSERT(git);
1183  return git->rm_cached(file);
1184  }
1185  void cherrypick(QString const &name)
1186  {
1187  Q_ASSERT(git);
1188  git->cherrypick(name);
1189  }
1190  QString getCherryPicking() const
1191  {
1192  Q_ASSERT(git);
1193  return git->getCherryPicking();
1194  }
1195  QList<Git::Branch> branches()
1196  {
1197  Q_ASSERT(git);
1198  return git->branches();
1199  }
1200 
1201  QString signingKey(Git::Source purpose)
1202  {
1203  Q_ASSERT(git);
1204  return git->signingKey(purpose);
1205  }
1206  bool setSigningKey(QString const &id, bool global)
1207  {
1208  Q_ASSERT(git);
1209  return git->setSigningKey(id, global);
1210  }
1212  {
1213  Q_ASSERT(git);
1214  return git->signPolicy(source);
1215  }
1217  {
1218  Q_ASSERT(git);
1219  return git->setSignPolicy(source, policy);
1220  }
1221  bool configGpgProgram(QString const &path, bool global)
1222  {
1223  Q_ASSERT(git);
1224  return git->configGpgProgram(path, global);
1225  }
1226 
1227  bool reflog(Git::ReflogItemList *out, int maxcount = 100)
1228  {
1229  Q_ASSERT(git);
1230  return git->reflog(out, maxcount);
1231  }
1232  QByteArray blame(QString const &path)
1233  {
1234  Q_ASSERT(git);
1235  return git->blame(path);
1236  }
1237 
1238  std::optional<std::vector<GitFileItem>> ls(const QString &path)
1239  {
1240  Q_ASSERT(git);
1241  return git->ls(path);
1242  }
1243  std::optional<std::vector<char>> readfile(const QString &path)
1244  {
1245  Q_ASSERT(git);
1246  return git->readfile(path);
1247  }
1248 };
1249 
1250 #endif // GIT_H
ApplicationGlobal * global
Definition: main.cpp:28
void parseDiff(const std::string_view &s, Git::Diff const *info, Git::Diff *out)
Definition: Git.cpp:1897
void parseGitSubModules(QByteArray const &ba, QList< Git::SubmoduleItem > *out)
Definition: Git.cpp:1938
LineSide
Definition: Git.h:13
#define GIT_ID_LENGTH
Definition: Git.h:10
QList< NamedCommitItem > NamedCommitList
Definition: Git.h:710
static bool operator==(Git::Hash const &l, Git::Hash const &r)
Definition: Git.h:716
static bool operator<(Git::Hash const &l, Git::Hash const &r)
Definition: Git.h:721
std::shared_ptr< Git > GitPtr
Definition: Git.h:736
Definition: AbstractProcess.h:11
Definition: GitCommandCache.h:9
Definition: Git.h:30
std::shared_ptr< AbstractGitSession > connect() const
Definition: Git.cpp:1989
QString ssh_command
Definition: Git.h:33
QString git_command
Definition: Git.h:32
Definition: Git.h:740
GitRunner dup() const
Definition: Git.cpp:1982
void unstage(QStringList const &paths)
Definition: Git.h:1139
QList< Git::SubmoduleItem > submodules()
Definition: Git.h:1051
QString workingDir() const
Definition: Git.h:796
bool configGpgProgram(QString const &path, bool global)
Definition: Git.h:1221
bool unstage_all()
Definition: Git.h:1118
bool checkout(QString const &branch_name, QString const &id={})
Definition: Git.h:981
QString diff(QString const &old_id, QString const &new_id)
Definition: Git.h:1082
void removeRemote(QString const &name)
Definition: Git.h:844
bool submodule_add(const Git::CloneData &data, bool force, AbstractPtyProcess *pty)
Definition: Git.h:1056
void setRemoteURL(const Git::Remote &remote)
Definition: Git.h:834
Git::CommitItemList log_all(Git::Hash const &id, int maxcount)
Definition: Git.h:1003
QList< Git::DiffRaw > diff_raw(Git::Hash const &old_id, Git::Hash const &new_id)
Definition: Git.h:1072
bool fetch(AbstractPtyProcess *pty=nullptr, bool prune=false)
Definition: Git.h:1150
QString diff_to_file(QString const &old_id, QString const &path)
Definition: Git.h:1092
QString signingKey(Git::Source purpose)
Definition: Git.h:1201
QString version()
Definition: Git.h:855
bool stash_drop()
Definition: Git.h:1045
bool checkout_detach(QString const &id)
Definition: Git.h:986
GitRunner()=default
void setSshKey(const QString &sshkey) const
Definition: Git.h:806
void cherrypick(QString const &name)
Definition: Git.h:1185
bool init()
Definition: Git.h:861
bool push_u(bool set_upstream, QString const &remote, QString const &branch, bool force, AbstractPtyProcess *pty)
Definition: Git.h:1170
bool setSignPolicy(Git::Source source, Git::SignPolicy policy)
Definition: Git.h:1216
bool reflog(Git::ReflogItemList *out, int maxcount=100)
Definition: Git.h:1227
bool commit_amend_m(QString const &text, bool sign, AbstractPtyProcess *pty)
Definition: Git.h:940
std::optional< Git::CommitItem > log_signature(Git::Hash const &id)
Definition: Git.h:1019
Git::FileStatusList status_s()
Definition: Git.h:1098
bool clean_df()
Definition: Git.h:1165
void setUser(Git::User const &user, bool global)
Definition: Git.h:905
static std::optional< Git::CommitItem > parseCommit(QByteArray const &ba)
Definition: Git.h:771
bool rm_cached(QString const &file)
Definition: Git.h:1180
void createBranch(QString const &name)
Definition: Git.h:960
bool commit(QString const &text, bool sign, AbstractPtyProcess *pty)
Definition: Git.h:935
GitRunner(GitRunner &&that)
Definition: Git.h:752
void checkoutBranch(QString const &name)
Definition: Git.h:965
QString const & sshKey() const
Definition: Git.h:801
void unstage(QString const &path)
Definition: Git.h:1134
QList< Git::Branch > branches()
Definition: Git.h:1195
bool delete_tag(QString const &name, bool remote)
Definition: Git.h:877
std::optional< std::vector< GitFileItem > > ls(const QString &path)
Definition: Git.h:1238
void addRemoteURL(const Git::Remote &remote)
Definition: Git.h:839
bool setSigningKey(QString const &id, bool global)
Definition: Git.h:1206
QString queryEntireCommitMessage(const Git::Hash &id)
Definition: Git.h:1066
std::optional< QByteArray > cat_file(const Git::Hash &id)
Definition: Git.h:1103
QDateTime repositoryLastModifiedTime()
Definition: Git.h:925
bool stash()
Definition: Git.h:1035
bool push_tags(AbstractPtyProcess *pty=nullptr)
Definition: Git.h:950
bool isValidWorkingCopy(QString const &dir) const
Definition: Git.h:776
QString diff_file(QString const &old_path, QString const &new_path)
Definition: Git.h:1087
void setDefaultBranch(QString const &branchname)
Definition: Git.h:915
std::optional< std::vector< char > > readfile(const QString &path)
Definition: Git.h:1243
QString errorMessage(std::optional< GitResult > const &var) const
Definition: Git.h:817
void add_A()
Definition: Git.h:1113
QString getDefaultBranch()
Definition: Git.h:910
void removeFile(QString const &path, bool rm_real_file)
Definition: Git.h:894
void resetFile(QString const &path)
Definition: Git.h:883
std::string diff_head(std::function< bool(std::string const &name, std::string const &mime)> fn_accept=nullptr)
Definition: Git.h:1077
QList< Git::Tag > tags()
Definition: Git.h:867
QStringList getRemotes()
Definition: Git.h:849
void rebase_abort()
Definition: Git.h:997
void setSubmodulePath(const QString &submodpath)
Definition: Git.h:791
void resetAllFiles()
Definition: Git.h:888
Git::SignPolicy signPolicy(Git::Source source)
Definition: Git.h:1211
bool stash_apply()
Definition: Git.h:1040
GitRunner(GitRunner const &that)
Definition: Git.h:748
Git::CommitItemList log(int maxcount)
Definition: Git.h:1024
bool isValidWorkingCopy() const
Definition: Git.h:781
void mergeBranch(QString const &name, Git::MergeFastForward ff, bool squash)
Definition: Git.h:970
void operator=(GitRunner const &that)
Definition: Git.h:756
bool clone(Git::CloneData const &data, AbstractPtyProcess *pty)
Definition: Git.h:1108
QString objectType(const Git::Hash &id)
Definition: Git.h:1175
void clearCommandCache()
Definition: Git.h:766
void unsetDefaultBranch()
Definition: Git.h:920
Git::User getUser(Git::Source purpose)
Definition: Git.h:900
Git::CommitItemList log_file(QString const &path, int maxcount)
Definition: Git.h:1008
void stage(QString const &path)
Definition: Git.h:1124
bool tag(QString const &name, Git::Hash const &id={})
Definition: Git.h:872
QString status()
Definition: Git.h:930
GitRunner(GitPtr const &git)
Definition: Git.h:744
bool deleteBranch(QString const &name)
Definition: Git.h:975
Git::Hash rev_parse(QString const &name)
Definition: Git.h:829
void rebaseBranch(QString const &name)
Definition: Git.h:992
QStringList rev_list_all(Git::Hash const &id, int maxcount)
Definition: Git.h:1013
bool pull(AbstractPtyProcess *pty=nullptr)
Definition: Git.h:1144
bool stage(QStringList const &paths, AbstractPtyProcess *pty)
Definition: Git.h:1129
QByteArray blame(QString const &path)
Definition: Git.h:1232
std::optional< Git::CommitItem > queryCommitItem(const Git::Hash &id)
Definition: Git.h:1029
bool revert(const Git::Hash &id)
Definition: Git.h:945
void remote_v(std::vector< Git::Remote > *out)
Definition: Git.h:955
QString getMessage(const QString &id)
Definition: Git.h:812
bool reset_hard()
Definition: Git.h:1160
bool submodule_update(const Git::SubmoduleUpdateData &data, AbstractPtyProcess *pty)
Definition: Git.h:1061
bool remove(QString const &path)
Definition: Git.h:823
QString getCherryPicking() const
Definition: Git.h:1190
bool reset_head1()
Definition: Git.h:1155
GitPtr git
Definition: Git.h:742
void setWorkingRepositoryDir(QString const &repo, const QString &sshkey)
Definition: Git.h:786
Definition: Git.h:143
void resize(size_t n)
Definition: Git.h:151
CommitItem * find(Hash const &id)
Definition: Git.h:186
void clear()
Definition: Git.h:171
CommitItem & operator[](size_t i)
Definition: Git.h:163
bool empty() const
Definition: Git.h:175
CommitItem const * find(Hash const &id) const
Definition: Git.h:194
std::vector< CommitItem > list
Definition: Git.h:145
CommitItem const & at(size_t i) const
Definition: Git.h:159
void updateIndex()
Definition: Git.h:179
CommitItem & at(size_t i)
Definition: Git.h:155
size_t size() const
Definition: Git.h:147
std::map< Hash, size_t > index
Definition: Git.h:146
Definition: Git.h:205
QString diff
Definition: Git.h:218
QString path
Definition: Git.h:220
Type
Definition: Git.h:207
struct Git::Diff::SubmoduleDetail a_submodule
Diff()=default
Type type
Definition: Git.h:217
void makeForSingleFile(Diff *diff, QString const &id_a, QString const &id_b, QString const &path, QString const &mode)
Definition: Git.cpp:1884
QString index
Definition: Git.h:219
Diff(QString const &id, QString const &path, QString const &mode)
Definition: Git.h:232
QList< Hunk > hunks
Definition: Git.h:226
struct Git::Diff::SubmoduleDetail b_submodule
struct Git::Diff::BLOB_AB_ blob
bool isSubmodule() const
Definition: Git.h:236
QString mode
Definition: Git.h:221
Definition: Git.h:331
static FileStatusCode parseFileStatusCode(char x, char y)
Definition: Git.cpp:1719
bool isUnmerged() const
Definition: Git.h:350
void parse(QString const &text)
Definition: Git.cpp:1741
int code_x() const
Definition: Git.h:374
QString path2() const
Definition: Git.h:394
int code_y() const
Definition: Git.h:379
FileStatusCode code() const
Definition: Git.h:369
bool isDeleted() const
Definition: Git.h:384
FileStatus(QString const &text)
Definition: Git.h:364
QString path1() const
Definition: Git.h:389
FileStatus()=default
bool isStaged() const
Definition: Git.h:345
QString rawpath2() const
Definition: Git.h:404
bool isTracked() const
Definition: Git.h:355
QString rawpath1() const
Definition: Git.h:399
struct Git::FileStatus::Data data
Definition: Git.h:43
void assign(std::string_view const &qid)
Definition: Git.cpp:75
QString toQString(int maxlen=-1) const
Definition: Git.cpp:85
size_t _std_hash() const
Definition: Git.h:68
bool isValid() const
Definition: Git.cpp:101
uint8_t id_[GIT_ID_LENGTH/2]
Definition: Git.h:46
int compare(Hash const &other) const
Definition: Git.h:57
Hash()
Definition: Git.h:49
bool valid_
Definition: Git.h:45
void _assign(VIEW const &id)
Definition: Git.cpp:50
Definition: Git.h:200
std::vector< std::string > lines
Definition: Git.h:203
std::string at
Definition: Git.h:202
Definition: Git.h:38
bool reflog(ReflogItemList *out, int maxcount=100)
Definition: Git.cpp:1607
QString getDefaultBranch()
Definition: Git.cpp:427
bool fetch(AbstractPtyProcess *pty=nullptr, bool prune=false)
Definition: Git.cpp:1342
QStringList getRemotes()
Definition: Git.cpp:1452
Source
Definition: Git.h:616
static bool isUncommited(CommitItem const &item)
Definition: Git.h:266
QString getCurrentBranchName()
Definition: Git.cpp:449
bool stash_drop()
Definition: Git.cpp:1528
std::optional< GitResult > git_nolog(QString const &arg, AbstractPtyProcess *pty)
Definition: Git.h:463
std::optional< GitResult > git(QString const &arg)
Definition: Git.h:459
void resetAllFiles()
Definition: Git.cpp:1271
SignPolicy
Definition: Git.h:656
@ Unset
Definition: Git.h:657
@ False
Definition: Git.h:658
@ True
Definition: Git.h:659
CommitItemList log(int maxcount)
Definition: Git.cpp:784
bool isValidWorkingCopy() const
Definition: Git.cpp:236
QStringList rev_list_all(Hash const &id, int maxcount)
Definition: Git.cpp:764
void setWorkingRepositoryDir(QString const &repo, const QString &sshkey)
Definition: Git.cpp:140
void unsetDefaultBranch()
Definition: Git.cpp:442
void setUser(User const &user, bool global)
Definition: Git.cpp:1490
QString status()
Definition: Git.cpp:186
std::string resultStdString(const std::optional< GitResult > &var) const
Definition: Git.cpp:202
QByteArray blame(QString const &path)
Definition: Git.cpp:1767
CommitItemList log_file(QString const &path, int maxcount)
Definition: Git.cpp:740
void rebase_abort()
Definition: Git.cpp:1447
static bool isValidID(QString const &id)
Definition: Git.cpp:162
bool pull(AbstractPtyProcess *pty=nullptr)
Definition: Git.cpp:1335
QList< DiffRaw > diff_raw(Hash const &old_id, Hash const &new_id)
Definition: Git.cpp:385
void rm(QString const &path, bool rm_real_file)
Definition: Git.cpp:1276
Hash rev_parse(QString const &name)
Definition: Git.cpp:289
AbstractGitSession::Info const & gitinfo() const
Definition: Git.h:433
AbstractGitSession::Info & gitinfo()
Definition: Git.h:429
QDateTime repositoryLastModifiedTime()
Definition: Git.cpp:789
bool commit_(QString const &msg, bool amend, bool sign, AbstractPtyProcess *pty)
Definition: Git.cpp:1132
FileStatusList status_s()
Definition: Git.cpp:1218
std::optional< GitResult > exec_git(QString const &arg, AbstractGitSession::Option const &opt)
Definition: Git.h:455
QString version()
Definition: Git.cpp:265
QString diff_file(QString const &old_path, QString const &new_path)
Definition: Git.cpp:351
bool stash_apply()
Definition: Git.cpp:1523
QString getCherryPicking() const
Definition: Git.cpp:1380
QList< ReflogItem > ReflogItemList
Definition: Git.h:651
QList< RemoteInfo > ls_remote()
Definition: Git.cpp:1778
bool tag(QString const &name, Hash const &id={})
Definition: Git.cpp:321
~Git()=default
QString encodeQuotedText(QString const &str)
Definition: Git.cpp:1110
QList< SubmoduleItem > submodules()
Definition: Git.cpp:1048
void createBranch(QString const &name)
Definition: Git.cpp:1365
QString workingDir() const
Definition: Git.h:485
QString const & sshKey() const
Definition: Git.cpp:152
bool remove(QString const &path)
Definition: Git.h:477
void cherrypick(QString const &name)
Definition: Git.cpp:1375
bool configGpgProgram(QString const &path, bool global)
Definition: Git.cpp:1866
bool rm_cached(QString const &file)
Definition: Git.cpp:1533
static std::optional< CommitItem > parseCommitItem(const QString &line)
Definition: Git.cpp:670
SignatureGrade
Definition: Git.h:106
bool commit(QString const &text, bool sign, AbstractPtyProcess *pty)
Definition: Git.cpp:1154
static QString trimPath(QString const &s)
Definition: Git.cpp:1688
void setRemoteURL(const Remote &remote)
Definition: Git.cpp:1585
void checkoutBranch(QString const &name)
Definition: Git.cpp:1370
bool clone(CloneData const &data, AbstractPtyProcess *pty)
Definition: Git.cpp:1021
CommitItemList log_all(Hash const &id, int maxcount)
コミットログを取得する
Definition: Git.cpp:716
void add_A()
Definition: Git.cpp:1285
SignPolicy signPolicy(Source source)
Definition: Git.cpp:1827
void setCommandCache(GitCommandCache const &cc)
Definition: Git.h:443
std::optional< CommitItem > queryCommitItem(const Hash &id)
Definition: Git.cpp:977
FileStatusCode
Definition: Git.h:303
User getUser(Source purpose)
Definition: Git.cpp:1465
void removeRemote(QString const &name)
Definition: Git.cpp:1600
void unstage(QString const &path)
Definition: Git.cpp:1312
static SignatureGrade evaluateSignature(char c)
Definition: Git.h:244
QString diff_to_file(QString const &old_id, QString const &path)
Definition: Git.cpp:419
void _init(const GitContext &cx)
Definition: Git.cpp:135
QString errorMessage(const std::optional< GitResult > &var) const
Definition: Git.cpp:219
std::vector< FileStatus > FileStatusList
Definition: Git.h:409
QByteArray toQByteArray(const std::optional< GitResult > &var) const
Definition: Git.cpp:194
std::optional< CommitItem > log_signature(Hash const &id)
Git::log_signature.
Definition: Git.cpp:817
void stage(QString const &path)
Definition: Git.cpp:1290
bool clean_df()
Definition: Git.cpp:1513
bool stash()
Definition: Git.cpp:1518
std::optional< QByteArray > cat_file(Hash const &id)
Definition: Git.cpp:1232
QString signingKey(Source purpose)
Definition: Git.cpp:1798
bool revert(const Hash &id)
Definition: Git.cpp:1164
void addRemoteURL(const Remote &remote)
Definition: Git.cpp:1592
void setDefaultBranch(QString const &branchname)
Definition: Git.cpp:435
void clearCommandCache()
Definition: Git.cpp:130
bool unstage_all()
Definition: Git.cpp:1330
bool submodule_update(const SubmoduleUpdateData &data, AbstractPtyProcess *pty)
Definition: Git.cpp:1095
void rebaseBranch(QString const &name)
Definition: Git.cpp:1442
FileStatusList status_s_()
Definition: Git.cpp:1197
QString diff(QString const &old_id, QString const &new_id)
Definition: Git.cpp:343
QString resultQString(const std::optional< GitResult > &var) const
Definition: Git.cpp:210
bool commit_amend_m(QString const &text, bool sign, AbstractPtyProcess *pty)
Definition: Git.cpp:1159
QString objectType(const Hash &id)
Definition: Git.cpp:1223
void setSshKey(const QString &sshkey)
Definition: Git.cpp:157
bool setSigningKey(QString const &id, bool global)
Definition: Git.cpp:1814
Git(Git &&r)=delete
bool push_tags(AbstractPtyProcess *pty=nullptr)
Definition: Git.cpp:1189
bool reset_head1()
Definition: Git.cpp:1503
void resetFile(QString const &path)
Definition: Git.cpp:1266
std::optional< std::vector< GitFileItem > > ls(const QString &path)
Definition: Git.cpp:800
QStringList getUntrackedFiles()
Definition: Git.cpp:461
static bool isValidID(Hash const &id)
Definition: Git.h:573
bool checkout(QString const &branch_name, QString const &id={})
Definition: Git.cpp:1425
bool checkout_detach(QString const &id)
Definition: Git.cpp:1437
static CloneData preclone(QString const &url, QString const &path)
Definition: Git.cpp:992
void mergeBranch(QString const &name, MergeFastForward ff, bool squash)
Definition: Git.cpp:1400
QString queryEntireCommitMessage(const Hash &id)
Definition: Git.cpp:1241
bool deleteBranch(QString const &name)
Definition: Git.cpp:1420
QList< Branch > branches()
Definition: Git.cpp:539
MergeFastForward
Definition: Git.h:325
QList< Tag > tags()
Definition: Git.cpp:302
std::optional< std::vector< char > > readfile(const QString &path)
Definition: Git.cpp:805
bool delete_tag(QString const &name, bool remote)
Definition: Git.cpp:328
QStringList make_branch_list_(const std::optional< GitResult > &result)
Definition: Git.cpp:1354
static void parseAheadBehind(QString const &s, Branch *b)
Definition: Git.cpp:473
bool reset_hard()
Definition: Git.cpp:1508
static std::optional< CommitItem > parseCommit(QByteArray const &ba)
Definition: Git.cpp:878
std::optional< GitResult > git_nochdir(QString const &arg, AbstractPtyProcess *pty)
Definition: Git.h:470
void remote_v(std::vector< Remote > *out)
Definition: Git.cpp:1539
bool submodule_add(const CloneData &data, bool force, AbstractPtyProcess *pty)
Definition: Git.cpp:1077
std::string diff_head(std::function< bool(std::string const &, std::string const &)> fn_accept=nullptr)
Definition: Git.cpp:359
bool setSignPolicy(Source source, SignPolicy policy)
Definition: Git.cpp:1845
bool push_u(bool set_upstream, QString const &remote, QString const &branch, bool force, AbstractPtyProcess *pty)
Definition: Git.cpp:1171
bool isValidGitCommand() const
Definition: Git.h:449
bool init()
Definition: Git.cpp:271
std::shared_ptr< AbstractGitSession > session_
Definition: Git.h:41
Git()
Definition: Git.cpp:119
QString getMessage(const QString &id)
Definition: Git.cpp:1394
void setSubmodulePath(const QString &submodpath)
Definition: Git.cpp:146
static bool isValidMailAddress(const QString &email)
文字列が有効なメールアドレスか判定する
Definition: misc.cpp:748
uint32_t crc32(uint32_t in, void const *data, size_t size)
Definition: crc32.cpp:2
static Variant var(jstream::Reader const &reader)
Definition: jstream.h:1612
Definition: Git.h:726
Definition: AbstractGitSession.h:64
Definition: AbstractGitSession.h:56
AbstractPtyProcess * pty
Definition: AbstractGitSession.h:61
bool log
Definition: AbstractGitSession.h:59
bool chdir
Definition: AbstractGitSession.h:58
Definition: Git.h:271
int flags
Definition: Git.h:283
bool isHeadDetached() const
Definition: Git.h:292
int behind
Definition: Git.h:276
@ None
Definition: Git.h:278
@ Current
Definition: Git.h:279
@ HeadDetachedFrom
Definition: Git.h:281
@ HeadDetachedAt
Definition: Git.h:280
QString remote
Definition: Git.h:274
QString name
Definition: Git.h:272
int ahead
Definition: Git.h:275
bool isCurrent() const
Definition: Git.h:288
Hash id
Definition: Git.h:273
Definition: Git.h:506
QString subdir
Definition: Git.h:509
QString url
Definition: Git.h:507
QString basedir
Definition: Git.h:508
Definition: Git.h:115
QList< Hash > parent_ids
Definition: Git.h:118
void setParents(QStringList const &list)
Definition: Git.cpp:111
bool has_gpgsig
Definition: Git.h:124
bool has_child
Definition: Git.h:132
bool order_fixed
Definition: Git.h:135
QString email
Definition: Git.h:120
std::vector< TreeLine > parent_lines
Definition: Git.h:123
QString message
Definition: Git.h:121
QDateTime commit_date
Definition: Git.h:122
QString text
Definition: Git.h:127
QString author
Definition: Git.h:119
bool resolved
Definition: Git.h:134
std::vector< uint8_t > key_fingerprint
Definition: Git.h:129
Hash commit_id
Definition: Git.h:116
QString gpgsig
Definition: Git.h:125
char verify
Definition: Git.h:128
Hash tree
Definition: Git.h:117
QString trust
Definition: Git.h:130
int marker_depth
Definition: Git.h:133
struct Git::CommitItem::@7 sign
Definition: Git.h:542
QString id
Definition: Git.h:543
QString mode
Definition: Git.h:544
Definition: Git.h:541
QStringList files
Definition: Git.h:547
struct Git::DiffRaw::AB b
struct Git::DiffRaw::AB a
QString state
Definition: Git.h:546
Definition: Git.h:222
QString b_id_or_path
Definition: Git.h:224
QString a_id_or_path
Definition: Git.h:223
Definition: Git.h:227
CommitItem commit
Definition: Git.h:229
SubmoduleItem item
Definition: Git.h:228
Definition: Git.h:333
QString rawpath1
Definition: Git.h:337
char code_y
Definition: Git.h:335
FileStatusCode code
Definition: Git.h:336
QString path1
Definition: Git.h:339
QString path2
Definition: Git.h:340
char code_x
Definition: Git.h:334
QString rawpath2
Definition: Git.h:338
Definition: Git.h:74
Type
Definition: Git.h:75
QByteArray content
Definition: Git.h:87
Type type
Definition: Git.h:86
Definition: Git.h:641
QString type
Definition: Git.h:646
QString path
Definition: Git.h:647
QString atts_a
Definition: Git.h:642
QString id_a
Definition: Git.h:644
QString id_b
Definition: Git.h:645
QString atts_b
Definition: Git.h:643
Definition: Git.h:636
QString message
Definition: Git.h:640
QList< File > files
Definition: Git.h:649
QString id
Definition: Git.h:637
QString head
Definition: Git.h:638
QString command
Definition: Git.h:639
Definition: Git.h:667
QString name
Definition: Git.h:669
QString commit_id
Definition: Git.h:668
Definition: Git.h:550
QString url_push
Definition: Git.h:553
QString ssh_key
Definition: Git.h:554
bool operator<(Remote const &r) const
Definition: Git.h:555
void set_url(QString const &url)
Definition: Git.h:563
QString const & url() const
Definition: Git.h:559
QString name
Definition: Git.h:551
QString url_fetch
Definition: Git.h:552
Definition: Git.h:94
QString name
Definition: Git.h:95
QString refs
Definition: Git.h:98
QString url
Definition: Git.h:99
QString path
Definition: Git.h:97
Hash id
Definition: Git.h:96
Definition: Git.h:677
bool recursive
Definition: Git.h:679
bool init
Definition: Git.h:678
Definition: Git.h:298
QString name
Definition: Git.h:299
Hash id
Definition: Git.h:300
Definition: Git.h:608
QString email
Definition: Git.h:610
QString name
Definition: Git.h:609
Definition: Git.h:698
Type type
Definition: Git.h:705
QString remote
Definition: Git.h:706
Type
Definition: Git.h:699
Git::Hash id
Definition: Git.h:708
QString name
Definition: Git.h:707
Definition: Git.h:18
TreeLine(int index=-1, int depth=-1)
Definition: Git.h:23
bool bend_early
Definition: Git.h:22
int depth
Definition: Git.h:20
int index
Definition: Git.h:19
int color_number
Definition: Git.h:21