From ec27dc95133d31de242f924528916980053c51e1 Mon Sep 17 00:00:00 2001 From: Yue Lin Ho Date: Thu, 4 Jun 2015 22:24:35 +0800 Subject: [PATCH] Refactored: Replace 'count' parameter of CGit::GetLogCmd() with CFilterData::m_NumberOfLogs Signed-off-by: Yue Lin Ho --- src/Git/Git.cpp | 8 ++++---- src/Git/Git.h | 4 +++- src/TortoiseProc/GitLogListBase.cpp | 4 ++-- src/TortoiseProc/LogDataVector.cpp | 4 +++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Git/Git.cpp b/src/Git/Git.cpp index 68bf7758d..d7c8dc53c 100644 --- a/src/Git/Git.cpp +++ b/src/Git/Git.cpp @@ -940,7 +940,7 @@ int CGit::BuildOutputFormat(CString &format,bool IsFull) return 0; } -CString CGit::GetLogCmd(const CString &range, const CTGitPath *path, int count, int mask, bool paramonly, +CString CGit::GetLogCmd(const CString& range, const CTGitPath* path, int mask, bool paramonly, CFilterData *Filter) { CString cmd; @@ -952,9 +952,6 @@ CString CGit::GetLogCmd(const CString &range, const CTGitPath *path, int count, if(path) file.Format(_T(" -- \"%s\""), (LPCTSTR)path->GetGitPathString()); - if(count>0) - num.Format(_T("-n%d"),count); - CString param; if(mask& LOG_INFO_STAT ) @@ -1002,6 +999,9 @@ CString CGit::GetLogCmd(const CString &range, const CTGitPath *path, int count, CString st1,st2; + if (Filter && Filter->m_NumberOfLogs > 0) + num.Format(_T("-n%d"), Filter->m_NumberOfLogs); + if( Filter && (Filter->m_From != -1)) { st1.Format(_T(" --max-age=%I64u "), Filter->m_From); diff --git a/src/Git/Git.h b/src/Git/Git.h index 75702dc88..9e50c100d 100644 --- a/src/Git/Git.h +++ b/src/Git/Git.h @@ -40,7 +40,9 @@ public: { m_From=m_To=-1; m_IsRegex=1; + m_NumberOfLogs = 0; } + DWORD m_NumberOfLogs; __time64_t m_From; __time64_t m_To; CString m_Author; @@ -352,7 +354,7 @@ public: CString FixBranchName_Mod(CString& branchName); CString FixBranchName(const CString& branchName); - CString GetLogCmd(const CString &range, const CTGitPath *path = NULL, int count=-1, int InfoMask = LOG_INFO_FULL_DIFF|LOG_INFO_STAT|LOG_INFO_FILESTATE|LOG_INFO_BOUNDARY|LOG_INFO_DETECT_COPYRENAME|LOG_INFO_SHOW_MERGEDFILE, bool paramonly=false, CFilterData * filter =NULL); + CString GetLogCmd(const CString& range, const CTGitPath* path = nullptr, int InfoMask = LOG_INFO_FULL_DIFF | LOG_INFO_STAT | LOG_INFO_FILESTATE | LOG_INFO_BOUNDARY | LOG_INFO_DETECT_COPYRENAME | LOG_INFO_SHOW_MERGEDFILE, bool paramonly = false, CFilterData* filter = nullptr); int GetHash(CGitHash &hash, const CString& friendname); static int GetHash(git_repository * repo, CGitHash &hash, const CString& friendname, bool skipFastCheck = false); diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index 3d8499356..4fd744532 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -2673,7 +2673,7 @@ int CGitLogListBase::BeginFetchLog() if (mask & CGit::LOG_INFO_FOLLOW) mask &= ~CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_LOCAL_BRANCHES; - CString cmd = g_Git.GetLogCmd(m_sRange, path, -1, mask, true, &m_Filter); + CString cmd = g_Git.GetLogCmd(m_sRange, path, mask, true, &m_Filter); //this->m_logEntries.ParserFromLog(); if(IsInWorkingThread()) @@ -2708,7 +2708,7 @@ int CGitLogListBase::BeginFetchLog() if (list.size() == 0) return 0; - cmd = g_Git.GetLogCmd(list[0], path, -1, mask, true, &m_Filter); + cmd = g_Git.GetLogCmd(list[0], path, mask, true, &m_Filter); } g_Git.m_critGitDllSec.Lock(); diff --git a/src/TortoiseProc/LogDataVector.cpp b/src/TortoiseProc/LogDataVector.cpp index 1e4d27f4b..c56ad7e1d 100644 --- a/src/TortoiseProc/LogDataVector.cpp +++ b/src/TortoiseProc/LogDataVector.cpp @@ -64,7 +64,9 @@ int CLogDataVector::ParserFromLog(CTGitPath *path, int count, int infomask, CStr CString gitrange = _T("HEAD"); if (range != nullptr) gitrange = *range; - CString cmd = g_Git.GetLogCmd(gitrange, path, count, infomask, true); + CFilterData filter; + filter.m_NumberOfLogs = count; + CString cmd = g_Git.GetLogCmd(gitrange, path, infomask, true, &filter); if (!g_Git.CanParseRev(gitrange)) return 0; -- 2.11.4.GIT