1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013, 2015-2017 - 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.
19 // CTortoiseGitBlameData.h : interface of the CTortoiseGitBlameData class
25 #include "gitlogcache.h"
26 #include <unordered_set>
28 class CTortoiseGitBlameData
32 CTortoiseGitBlameData();
33 virtual ~CTortoiseGitBlameData();
36 int GetEncode(unsigned char * buffer
, int size
, int *bomoffset
);
37 int GetEncode(int *bomoffset
);
38 void ParseBlameOutput(BYTE_VECTOR
&data
, CGitHashMap
& HashToRev
, DWORD dateFormat
, bool bRelativeTimes
);
39 // updates sourcecode lines to the given encoding, encode==0 detects the encoding, returns the used encoding
40 int UpdateEncoding(int encode
= 0);
42 BOOL
IsValidLine(int line
)
44 return line
>= 0 && line
< (int)m_Hash
.size();
46 int FindNextLine(CGitHash
& commithash
, int line
, bool bUpOrDown
=false);
47 // find first line with the given hash starting with given "line"
48 int FindFirstLine(CGitHash
& commithash
, int line
)
50 int numberOfLines
= (int)GetNumberOfLines();
51 for (int i
= (line
>= 0 ? line
: 0); i
< numberOfLines
; ++i
)
53 if (m_Hash
[i
] == commithash
)
58 // find first line of the current block with the given hash starting with given "line"
59 int FindFirstLineInBlock(CGitHash
& commithash
, int line
)
63 if (m_Hash
[line
] != commithash
)
69 enum SearchDirection
{ SearchNext
= 0, SearchPrevious
= 1 };
70 int FindFirstLineWrapAround(SearchDirection direction
, const CString
& what
, int line
, bool bCaseSensitive
);
72 int GetNumberOfLines() const
74 return (int)m_Hash
.size();
77 CGitHash
& GetHash(int line
)
82 void GetHashes(std::unordered_set
<CGitHash
>& hashes
)
85 for (const auto& hash
: m_Hash
)
91 const CString
& GetDate(int line
) const
96 const CString
& GetAuthor(int line
) const
98 return m_Authors
[line
];
101 const CString
& GetFilename(int line
) const
103 return m_Filenames
[line
];
106 int GetOriginalLineNumber(int line
) const
108 return m_OriginalLineNumbers
[line
];
111 const CStringA
& GetUtf8Line(int line
) const
113 return m_Utf8Lines
[line
];
116 bool ContainsOnlyFilename(const CString
&filename
) const;
118 GitRevLoglist
* GetRev(int line
, CGitHashMap
& hashToRev
)
120 return GetRevForHash(hashToRev
, GetHash(line
));
124 static GitRevLoglist
* GetRevForHash(CGitHashMap
& HashToRev
, const CGitHash
& hash
, CString
* err
= nullptr);
125 static CString
UnquoteFilename(CStringA
& s
);
127 std::vector
<CGitHash
> m_Hash
;
128 std::vector
<CString
> m_Dates
;
129 std::vector
<CString
> m_Authors
;
130 std::vector
<CString
> m_Filenames
;
131 std::vector
<int> m_OriginalLineNumbers
;
132 std::vector
<BYTE_VECTOR
> m_RawLines
;
135 std::vector
<CStringA
> m_Utf8Lines
;