Minor cleanup
[TortoiseGit.git] / src / Git / GitRev.h
blobcd229b1c9cbbaa73c0ccbc591dfd0424e369e320
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2015 - 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 "GitStatus.h"
23 #include "AtlTime.h"
24 #include "GitHash.h"
25 #include "GitDll.h"
27 typedef std::vector<CGitHash> GIT_REV_LIST;
29 #define LOG_REV_AUTHOR_NAME _T('0')
30 #define LOG_REV_AUTHOR_EMAIL _T('1')
31 #define LOG_REV_AUTHOR_DATE _T('2')
32 #define LOG_REV_COMMIT_NAME _T('3')
33 #define LOG_REV_COMMIT_EMAIL _T('4')
34 #define LOG_REV_COMMIT_DATE _T('5')
35 #define LOG_REV_COMMIT_SUBJECT _T('6')
36 #define LOG_REV_COMMIT_BODY _T('7')
37 #define LOG_REV_COMMIT_HASH _T('8')
38 #define LOG_REV_COMMIT_PARENT _T('9')
39 #define LOG_REV_COMMIT_FILE _T('A')
40 #define LOG_REV_ITEM_BEGIN _T('B')
41 #define LOG_REV_ITEM_END _T('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(void);
59 CString GetAuthorName()
61 return m_AuthorName;
64 CString GetAuthorEmail()
66 return m_AuthorEmail;
69 CTime GetAuthorDate()
71 return m_AuthorDate;
74 CString GetCommitterName()
76 return m_CommitterName;
79 CString GetCommitterEmail()
81 return m_CommitterEmail;
84 CTime GetCommitterDate()
86 return m_CommitterDate;
89 CString GetSubject()
91 return m_Subject;
94 CString GetBody()
96 return m_Body;
99 virtual ~GitRev(void);
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 CString(_T("HEAD"));};
110 static CString GetWorkingCopy(){return CString(GIT_REV_ZERO);};
112 CGitHash m_CommitHash;
113 GIT_REV_LIST m_ParentHash;
115 virtual void Clear();
116 inline int ParentsCount(){ return (int)m_ParentHash.size(); }
118 int ParserFromCommit(GIT_COMMIT *commit);
119 int ParserParentFromCommit(GIT_COMMIT *commit);
121 int ParserFromCommit(const git_commit* commit);
122 int ParserParentFromCommit(const git_commit* commit);
123 int GetCommitFromHash(git_repository* repo, const CGitHash& hash);
124 int GetCommit(git_repository* repo, const CString& Rev);
126 int GetParentFromHash(const CGitHash& hash);
127 int GetCommitFromHash(const CGitHash& hash);
128 int GetCommit(const CString& rev);
130 CString GetLastErr() { return m_sErr; }
132 void DbgPrint();
134 private:
135 int GetCommitFromHash_withoutLock(const CGitHash& hash);