1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2018-2020 - 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 #include "LogDlgFilter.h"
23 bool CLogDlgFilter::operator()(GitRevLoglist
* pRev
, CGitLogListBase
* loglist
, const MAP_HASH_NAME
& hashMapRefs
) const
25 if (!IsFilterActive())
26 return CalculateFinalResult(true);
28 // we need to perform expensive string / pattern matching
30 if (GetSelectedFilters() & (LOGFILTER_SUBJECT
| LOGFILTER_MESSAGES
))
32 scratch
+= pRev
->GetSubject();
35 if (GetSelectedFilters() & LOGFILTER_MESSAGES
)
37 scratch
+= pRev
->GetBody();
40 if (GetSelectedFilters() & LOGFILTER_BUGID
)
42 scratch
+= loglist
->m_ProjectProperties
.FindBugID(pRev
->GetSubjectBody());
45 if (GetSelectedFilters() & LOGFILTER_AUTHORS
)
47 scratch
+= pRev
->GetAuthorName();
49 scratch
+= pRev
->GetCommitterName();
52 if (GetSelectedFilters() & LOGFILTER_EMAILS
)
54 scratch
+= pRev
->GetAuthorEmail();
56 scratch
+= pRev
->GetCommitterEmail();
59 if (GetSelectedFilters() & LOGFILTER_REVS
)
61 scratch
+= pRev
->m_CommitHash
.ToString();
64 if (GetSelectedFilters() & LOGFILTER_NOTES
)
66 scratch
+= pRev
->m_Notes
;
69 if (GetSelectedFilters() & (LOGFILTER_REFNAME
| LOGFILTER_ANNOTATEDTAG
))
71 auto refList
= hashMapRefs
.find(pRev
->m_CommitHash
);
72 if (refList
!= hashMapRefs
.cend())
74 if (GetSelectedFilters() & LOGFILTER_REFNAME
)
76 for (const auto& ref
: (*refList
).second
)
82 if (GetSelectedFilters() & LOGFILTER_ANNOTATEDTAG
)
84 scratch
+= loglist
->GetTagInfo((*refList
).second
);
89 if (GetSelectedFilters() & LOGFILTER_PATHS
)
91 /* Because changed files list is loaded on demand when gui show, files will empty when files have not fetched.
92 we can add it back by using one-way diff(with outnumber changed and rename detect.
93 here just need changed filename list. one-way is much quicker.
95 if (pRev
->m_IsDiffFiles
|| loglist
->IsCached(pRev
))
97 auto pathList
= pRev
->GetFiles(loglist
);
98 for (int i
= 0; i
< pathList
.GetCount(); ++i
)
100 scratch
+= pathList
[i
].GetGitPathString();
102 scratch
+= pathList
[i
].GetGitOldPathString();
108 if (!pRev
->m_IsSimpleListReady
)
109 pRev
->SafeGetSimpleList(&g_Git
);
111 for (size_t i
= 0; i
< pRev
->m_SimpleFileList
.size(); ++i
)
113 scratch
+= pRev
->m_SimpleFileList
[i
];
119 return CalculateFinalResult(Match(scratch
));