Fix typos
[TortoiseGit.git] / src / Git / GitRev.h
blob043a185c4bbe7a77ca3a6e9e4e1c4e91e6c4350f
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2017, 2019-2023 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
21 #include "gittype.h"
22 #include "AtlTime.h"
23 #include "GitHash.h"
24 #include "GitDll.h"
25 #include "GitMailmap.h"
27 using GIT_REV_LIST = std::vector<CGitHash>;
29 #define LOG_REV_AUTHOR_NAME L'0'
30 #define LOG_REV_AUTHOR_EMAIL L'1'
31 #define LOG_REV_AUTHOR_DATE L'2'
32 #define LOG_REV_COMMIT_NAME L'3'
33 #define LOG_REV_COMMIT_EMAIL L'4'
34 #define LOG_REV_COMMIT_DATE L'5'
35 #define LOG_REV_COMMIT_SUBJECT L'6'
36 #define LOG_REV_COMMIT_BODY L'7'
37 #define LOG_REV_COMMIT_HASH L'8'
38 #define LOG_REV_COMMIT_PARENT L'9'
39 #define LOG_REV_COMMIT_FILE L'A'
40 #define LOG_REV_ITEM_BEGIN L'B'
41 #define LOG_REV_ITEM_END L'C'
43 class GitRev
45 protected:
46 CString m_AuthorName;
47 CString m_AuthorEmail;
48 CTime m_AuthorDate;
49 CString m_CommitterName;
50 CString m_CommitterEmail;
51 CTime m_CommitterDate;
52 CString m_Subject;
53 CString m_Body;
55 CString m_sErr;
57 public:
58 GitRev();
59 CString GetAuthorName() const
61 return m_AuthorName;
64 CString GetAuthorEmail() const
66 return m_AuthorEmail;
69 CTime GetAuthorDate() const
71 return m_AuthorDate;
74 CString GetCommitterName() const
76 return m_CommitterName;
79 CString GetCommitterEmail() const
81 return m_CommitterEmail;
84 CTime GetCommitterDate() const
86 return m_CommitterDate;
89 CString GetSubject() const
91 return m_Subject;
94 CString GetBody() const
96 return m_Body;
99 virtual ~GitRev();
101 enum
103 REV_HEAD = -1, ///< head revision
104 REV_BASE = -2, ///< base revision
105 REV_WC = -3, ///< revision of the working copy
106 REV_UNSPECIFIED = -4, ///< unspecified revision
109 static CString GetHead() { return L"HEAD"; };
110 static CString GetWorkingCopy() { return GIT_REV_ZERO; };
112 CGitHash m_CommitHash;
113 GIT_REV_LIST m_ParentHash;
115 virtual void Clear();
116 inline int ParentsCount() const { return static_cast<int>(m_ParentHash.size()); }
118 protected:
119 int ParserFromCommit(const GIT_COMMIT* commit);
120 int ParserParentFromCommit(const GIT_COMMIT* commit);
122 int ParserFromCommit(const git_commit* commit);
123 int ParserParentFromCommit(const git_commit* commit);
124 int GetCommitFromHash(git_repository* repo, const CGitHash& hash);
125 int GetCommit(git_repository* repo, const CString& Rev);
127 public:
128 int GetParentFromHash(const CGitHash& hash);
129 int GetCommitFromHash(const CGitHash& hash);
130 int GetCommit(const CString& rev);
132 CString GetLastErr() const { return m_sErr; }
134 void ApplyMailmap(const CGitMailmap& mailmap = CGitMailmap());
136 #if DEBUG
137 void DbgPrint();
138 #endif
140 private:
141 int GetCommitFromHash_withoutLock(const CGitHash& hash);