From 02b4916a682573c3ff6ae74170ff63d0495201dc Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Thu, 30 Oct 2014 22:50:01 +0100 Subject: [PATCH] Constify methods Signed-off-by: Sven Strickroth --- src/Git/gittype.h | 8 +++---- src/TortoiseProc/AppUtils.cpp | 40 +++++++++++++++++------------------ src/TortoiseProc/AppUtils.h | 40 +++++++++++++++++------------------ src/TortoiseShell/GITPropertyPage.cpp | 4 ++-- src/TortoiseShell/GITPropertyPage.h | 2 +- 5 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/Git/gittype.h b/src/Git/gittype.h index 16cbdec07..fabb61aeb 100644 --- a/src/Git/gittype.h +++ b/src/Git/gittype.h @@ -34,14 +34,14 @@ public: CGitByteArray(){ m_critSec.Init(); } CComCriticalSection m_critSec; - int find(BYTE data,int start=0) + int find(BYTE data, int start = 0) const { for (unsigned int i = start; i < size(); ++i) if( at(i) == data ) return i; return -1; } - int RevertFind(BYTE data, int start=-1) + int RevertFind(BYTE data, int start = -1) const { if(start == -1) start = (int)size() - 1; @@ -54,7 +54,7 @@ public: return i; return -1; } - int findNextString(int start=0) + int findNextString(int start = 0) const { int pos=start; do @@ -72,7 +72,7 @@ public: return pos; } - int findData(const BYTE* dataToFind, size_t dataSize, int start=0) + int findData(const BYTE* dataToFind, size_t dataSize, int start = 0) const { //Pre checks if(empty()) diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index 4c6450f97..8f1311b9c 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -771,7 +771,7 @@ bool CAppUtils::LaunchRemoteSetting() /** * Launch the external blame viewer */ -bool CAppUtils::LaunchTortoiseBlame(const CString& sBlameFile,CString Rev,const CString& sParams) +bool CAppUtils::LaunchTortoiseBlame(const CString& sBlameFile, const CString& Rev, const CString& sParams) { CString viewer = _T("\"") + CPathUtils::GetAppDirectory(); viewer += _T("TortoiseGitBlame.exe"); @@ -1042,7 +1042,7 @@ bool CAppUtils::SetupDiffScripts(bool force, const CString& type) return true; } -bool CAppUtils::Export(CString *BashHash, const CTGitPath *orgPath) +bool CAppUtils::Export(const CString* BashHash, const CTGitPath* orgPath) { // ask from where the export has to be done CExportDlg dlg; @@ -1082,7 +1082,7 @@ bool CAppUtils::Export(CString *BashHash, const CTGitPath *orgPath) return false; } -bool CAppUtils::CreateBranchTag(bool IsTag,CString *CommitHash, bool switch_new_brach) +bool CAppUtils::CreateBranchTag(bool IsTag, const CString* CommitHash, bool switch_new_brach) { CCreateBranchTagDlg dlg; dlg.m_bIsTag=IsTag; @@ -1154,7 +1154,7 @@ bool CAppUtils::CreateBranchTag(bool IsTag,CString *CommitHash, bool switch_new_ return FALSE; } -bool CAppUtils::Switch(CString initialRefName) +bool CAppUtils::Switch(const CString& initialRefName) { CGitSwitchDlg dlg; if(!initialRefName.IsEmpty()) @@ -1176,7 +1176,7 @@ bool CAppUtils::Switch(CString initialRefName) return FALSE; } -bool CAppUtils::PerformSwitch(CString ref, bool bForce /* false */, CString sNewBranch /* CString() */, bool bBranchOverride /* false */, BOOL bTrack /* 2 */, bool bMerge /* false */) +bool CAppUtils::PerformSwitch(const CString& ref, bool bForce /* false */, const CString& sNewBranch /* CString() */, bool bBranchOverride /* false */, BOOL bTrack /* 2 */, bool bMerge /* false */) { CString cmd; CString track; @@ -1334,7 +1334,7 @@ bool CAppUtils::OpenIgnoreFile(CIgnoreFile &file, const CString& filename) return true; } -bool CAppUtils::IgnoreFile(CTGitPathList &path,bool IsMask) +bool CAppUtils::IgnoreFile(const CTGitPathList& path,bool IsMask) { CIgnoreDlg ignoreDlg; if (ignoreDlg.DoModal() == IDOK) @@ -1486,7 +1486,7 @@ static bool Reset(const CString& resetTo, int resetType) return ret == IDOK; } -bool CAppUtils::GitReset(CString *CommitHash,int type) +bool CAppUtils::GitReset(const CString* CommitHash, int type) { CResetDlg dlg; dlg.m_ResetType=type; @@ -1514,13 +1514,13 @@ void CAppUtils::DescribeConflictFile(bool mode, bool base,CString &descript) return; } -void CAppUtils::RemoveTempMergeFile(CTGitPath &path) +void CAppUtils::RemoveTempMergeFile(const CTGitPath& path) { ::DeleteFile(CAppUtils::GetMergeTempFile(_T("LOCAL"), path)); ::DeleteFile(CAppUtils::GetMergeTempFile(_T("REMOTE"), path)); ::DeleteFile(CAppUtils::GetMergeTempFile(_T("BASE"), path)); } -CString CAppUtils::GetMergeTempFile(CString type,CTGitPath &merge) +CString CAppUtils::GetMergeTempFile(const CString& type, const CTGitPath &merge) { CString file; file = g_Git.CombinePath(merge.GetWinPathString() + _T(".") + type + merge.GetFileExtension()); @@ -1528,7 +1528,7 @@ CString CAppUtils::GetMergeTempFile(CString type,CTGitPath &merge) return file; } -bool ParseHashesFromLsFile(BYTE_VECTOR &out, CString &hash1, CString &hash2, CString &hash3) +bool ParseHashesFromLsFile(const BYTE_VECTOR& out, CString& hash1, CString& hash2, CString& hash3) { int pos = 0; CString one; @@ -1565,7 +1565,7 @@ bool ParseHashesFromLsFile(BYTE_VECTOR &out, CString &hash1, CString &hash2, CSt return false; } -bool CAppUtils::ConflictEdit(CTGitPath& path, bool /*bAlternativeTool = false*/, bool revertTheirMy /*= false*/, HWND resolveMsgHwnd /*= nullptr*/) +bool CAppUtils::ConflictEdit(const CTGitPath& path, bool /*bAlternativeTool = false*/, bool revertTheirMy /*= false*/, HWND resolveMsgHwnd /*= nullptr*/) { bool bRet = false; @@ -2079,7 +2079,7 @@ CString CAppUtils::GetClipboardLink(const CString &skipGitPrefix, int paramsCoun return CString(_T("")); } -CString CAppUtils::ChooseRepository(CString *path) +CString CAppUtils::ChooseRepository(const CString* path) { CBrowseFolder browseFolder; CRegString regLastResopitory = CRegString(_T("Software\\TortoiseGit\\TortoiseProc\\LastRepo"),_T("")); @@ -2139,7 +2139,7 @@ bool CAppUtils::SendPatchMail(CTGitPathList& list, bool bIsMainWnd) return false; } -bool CAppUtils::SendPatchMail(CString &cmd, CString &formatpatchoutput, bool bIsMainWnd) +bool CAppUtils::SendPatchMail(const CString& cmd, const CString& formatpatchoutput, bool bIsMainWnd) { CTGitPathList list; CString log=formatpatchoutput; @@ -2183,7 +2183,7 @@ int CAppUtils::GetLogOutputEncode(CGit *pGit) return CUnicodeUtils::GetCPCode(output); } } -int CAppUtils::SaveCommitUnicodeFile(CString &filename, CString &message) +int CAppUtils::SaveCommitUnicodeFile(const CString& filename, CString &message) { try { @@ -2508,7 +2508,7 @@ static bool DoFetch(const CString& url, const bool fetchAllRemotes, const bool l return userResponse == IDOK; } -bool CAppUtils::Fetch(CString remoteName, bool allowRebase, bool allRemotes) +bool CAppUtils::Fetch(const CString& remoteName, bool allowRebase, bool allRemotes) { CPullFetchDlg dlg; dlg.m_PreSelectRemote = remoteName; @@ -2522,7 +2522,7 @@ bool CAppUtils::Fetch(CString remoteName, bool allowRebase, bool allRemotes) return false; } -bool CAppUtils::Push(CString selectLocalBranch) +bool CAppUtils::Push(const CString& selectLocalBranch) { CPushDlg dlg; dlg.m_BranchSourceName = selectLocalBranch; @@ -2653,7 +2653,7 @@ bool CAppUtils::Push(CString selectLocalBranch) return FALSE; } -bool CAppUtils::RequestPull(CString endrevision, CString repositoryUrl, bool bIsMainWnd) +bool CAppUtils::RequestPull(const CString& endrevision, const CString& repositoryUrl, bool bIsMainWnd) { CRequestPullDlg dlg; dlg.m_RepositoryURL = repositoryUrl; @@ -2805,7 +2805,7 @@ bool CAppUtils::CheckUserData() return true; } -BOOL CAppUtils::Commit(CString bugid,BOOL bWholeProject,CString &sLogMsg, +BOOL CAppUtils::Commit(const CString& bugid, BOOL bWholeProject, CString &sLogMsg, CTGitPathList &pathList, CTGitPathList &selectedList, bool bSelectFilesForCommit) @@ -2994,7 +2994,7 @@ BOOL CAppUtils::SVNDCommit() return FALSE; } -BOOL CAppUtils::Merge(CString *commit) +BOOL CAppUtils::Merge(const CString* commit) { if (!CheckUserData()) return FALSE; @@ -3271,7 +3271,7 @@ void CAppUtils::SetWindowTitle(HWND hWnd, const CString& urlorpath, const CStrin SetWindowText(hWnd, pathbuf); } -bool CAppUtils::BisectStart(CString lastGood, CString firstBad, bool bIsMainWnd) +bool CAppUtils::BisectStart(const CString& lastGood, const CString& firstBad, bool bIsMainWnd) { if (!g_Git.CheckCleanWorkTree()) { diff --git a/src/TortoiseProc/AppUtils.h b/src/TortoiseProc/AppUtils.h index 78d774296..d7bb958f6 100644 --- a/src/TortoiseProc/AppUtils.h +++ b/src/TortoiseProc/AppUtils.h @@ -113,7 +113,7 @@ public: * Launch the external blame viewer */ static bool LaunchTortoiseBlame( - const CString& sBlameFile, CString Rev, const CString& sParams = CString()); + const CString& sBlameFile, const CString& Rev, const CString& sParams = CString()); /** * Launch alternative editor @@ -147,16 +147,16 @@ public: bool bMerge = false, bool bCompact = false); - static bool Export(CString *BashHash = nullptr, const CTGitPath *orgPath = nullptr); - static bool CreateBranchTag(bool IsTag=TRUE,CString *CommitHash=NULL, bool switch_new_brach=false); - static bool Switch(CString initialRefName = CString()); - static bool PerformSwitch(CString ref, bool bForce = false, CString sNewBranch = CString(), bool bBranchOverride = false, BOOL bTrack = 2, bool bMerge = false); + static bool Export(const CString* BashHash = nullptr, const CTGitPath* orgPath = nullptr); + static bool CreateBranchTag(bool IsTag = TRUE, const CString* CommitHash = nullptr, bool switch_new_brach = false); + static bool Switch(const CString& initialRefName = CString()); + static bool PerformSwitch(const CString& ref, bool bForce = false, const CString& sNewBranch = CString(), bool bBranchOverride = false, BOOL bTrack = 2, bool bMerge = false); - static bool IgnoreFile(CTGitPathList &filelist,bool IsMask); - static bool GitReset(CString *CommitHash,int type=1); - static bool ConflictEdit(CTGitPath& file, bool bAlternativeTool = false, bool revertTheirMy = false, HWND resolveMsgHwnd = nullptr); + static bool IgnoreFile(const CTGitPathList& filelist, bool IsMask); + static bool GitReset(const CString* CommitHash, int type = 1); + static bool ConflictEdit(const CTGitPath& file, bool bAlternativeTool = false, bool revertTheirMy = false, HWND resolveMsgHwnd = nullptr); - static CString GetMergeTempFile(CString str,CTGitPath &merge); + static CString GetMergeTempFile(const CString& str, const CTGitPath& merge); static bool StashSave(const CString& msg = CString()); static bool StashApply(CString ref, bool showChanges = true); static bool StashPop(bool showChanges = true); @@ -168,20 +168,20 @@ public: static bool LaunchPAgent(const CString* keyfile = nullptr, const CString* pRemote = nullptr); static CString GetClipboardLink(const CString &skipGitPrefix = _T(""), int paramsCount = 0); - static CString ChooseRepository(CString *path); + static CString ChooseRepository(const CString* path); - static bool SendPatchMail(CTGitPathList &pathlist, bool bIsMainWnd = false); - static bool SendPatchMail(CString &cmd,CString &formatpatchoutput, bool bIsMainWnd = false); + static bool SendPatchMail(CTGitPathList& pathlist, bool bIsMainWnd = false); + static bool SendPatchMail(const CString& cmd, const CString& formatpatchoutput, bool bIsMainWnd = false); - static int SaveCommitUnicodeFile(CString &filename, CString &mesage); + static int SaveCommitUnicodeFile(const CString& filename, CString& mesage); static int GetLogOutputEncode(CGit *pGit=&g_Git); static bool Pull(bool showPush = false); static bool RebaseAfterFetch(const CString& upstream = _T("")); - static bool Fetch(CString remoteName = _T(""), bool allowRebase = false, bool allRemotes = false); - static bool Push(CString selectLocalBranch = CString()); - static bool RequestPull(CString endrevision = _T(""), CString repositoryUrl = _T(""), bool bIsMainWnd = false); + static bool Fetch(const CString& remoteName = _T(""), bool allowRebase = false, bool allRemotes = false); + static bool Push(const CString& selectLocalBranch = CString()); + static bool RequestPull(const CString& endrevision = _T(""), const CString& repositoryUrl = _T(""), bool bIsMainWnd = false); static bool CreateMultipleDirectory(const CString &dir); @@ -189,20 +189,20 @@ public: static bool CheckUserData(); - static BOOL Commit(CString bugid,BOOL bWholeProject,CString &sLogMsg, + static BOOL Commit(const CString& bugid, BOOL bWholeProject, CString &sLogMsg, CTGitPathList &pathList, CTGitPathList &selectedList, bool bSelectFilesForCommit); static BOOL SVNDCommit(); - static BOOL Merge(CString *commit =NULL); + static BOOL Merge(const CString* commit = nullptr); static BOOL MergeAbort(); - static void RemoveTempMergeFile(CTGitPath &path); + static void RemoveTempMergeFile(const CTGitPath& path); static void EditNote(GitRev *hash); static int GetMsysgitVersion(); static void MarkWindowAsUnpinnable(HWND hWnd); - static bool BisectStart(CString lastGood, CString firstBad, bool bIsMainWnd = false); + static bool BisectStart(const CString& lastGood, const CString& firstBad, bool bIsMainWnd = false); static int Git2GetUserPassword(git_cred **out, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload); diff --git a/src/TortoiseShell/GITPropertyPage.cpp b/src/TortoiseShell/GITPropertyPage.cpp index a0add8431..b748e01de 100644 --- a/src/TortoiseShell/GITPropertyPage.cpp +++ b/src/TortoiseShell/GITPropertyPage.cpp @@ -374,7 +374,7 @@ static int TreewalkCB_FindFileRecentCommit(const char *root, const git_tree_entr return 1; } -static git_commit * FindFileRecentCommit(git_repository *repository, CString path) +static git_commit* FindFileRecentCommit(git_repository* repository, const CString& path) { CAutoRevwalk walk; if (git_revwalk_new(walk.GetPointer(), repository)) @@ -458,7 +458,7 @@ static git_commit * FindFileRecentCommit(git_repository *repository, CString pat return commit.Detach(); } -void CGitPropertyPage::DisplayCommit(git_commit * commit, UINT hashLabel, UINT subjectLabel, UINT authorLabel, UINT dateLabel) +void CGitPropertyPage::DisplayCommit(const git_commit* commit, UINT hashLabel, UINT subjectLabel, UINT authorLabel, UINT dateLabel) { if (commit == NULL) { diff --git a/src/TortoiseShell/GITPropertyPage.h b/src/TortoiseShell/GITPropertyPage.h index e1f5e20bd..eb8683503 100644 --- a/src/TortoiseShell/GITPropertyPage.h +++ b/src/TortoiseShell/GITPropertyPage.h @@ -49,7 +49,7 @@ protected: * Initializes the property page. */ virtual void InitWorkfileView(); - void DisplayCommit(git_commit * commit, UINT hashLabel, UINT subjectLabel, UINT authorLabel, UINT dateLabel); + void DisplayCommit(const git_commit* commit, UINT hashLabel, UINT subjectLabel, UINT authorLabel, UINT dateLabel); static void LogThreadEntry(void *param); int LogThread(); void Time64ToTimeString(__time64_t time, TCHAR * buf, size_t buflen) const; -- 2.11.4.GIT