From 763bbb991ff1a0572419cd350ea4a2a7a497673a Mon Sep 17 00:00:00 2001 From: Yue Lin Ho Date: Sun, 25 Sep 2016 20:16:43 +0800 Subject: [PATCH] Ignore ref. range of git log while showing all references Steps: 1. Create branches A, B 2. Show branches "A B" 3. Delete branch B 4. Click show all branches -> error Signed-off-by: Yue Lin Ho Signed-off-by: Sven Strickroth --- src/Git/Git.cpp | 9 ++++++++- src/Git/Git.h | 2 +- test/UnitTests/LogDataVectorTest.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Git/Git.cpp b/src/Git/Git.cpp index d55cffa78..02064c602 100644 --- a/src/Git/Git.cpp +++ b/src/Git/Git.cpp @@ -989,7 +989,7 @@ int CGit::BuildOutputFormat(CString &format,bool IsFull) return 0; } -CString CGit::GetLogCmd(const CString& range, const CTGitPath* path, int mask, CFilterData* Filter, int logOrderBy) +CString CGit::GetLogCmd(CString range, const CTGitPath* path, int mask, CFilterData* Filter, int logOrderBy) { CString param; @@ -1005,7 +1005,10 @@ CString CGit::GetLogCmd(const CString& range, const CTGitPath* path, int mask, C param += _T(" --left-right --boundary"); if(mask& CGit::LOG_INFO_ALL_BRANCH) + { param += _T(" --all"); + range.Empty(); + } if (mask& CGit::LOG_INFO_BASIC_REFS) { @@ -1014,10 +1017,14 @@ CString CGit::GetLogCmd(const CString& range, const CTGitPath* path, int mask, C param += _T(" --remotes"); param += _T(" --glob=stas[h]"); // require at least one glob operator param += _T(" --glob=bisect"); + range.Empty(); } if(mask & CGit::LOG_INFO_LOCAL_BRANCHES) + { param += _T(" --branches"); + range.Empty(); + } if(mask& CGit::LOG_INFO_DETECT_COPYRENAME) param += _T(" -C"); diff --git a/src/Git/Git.h b/src/Git/Git.h index d2120c8b2..5e7a9ee02 100644 --- a/src/Git/Git.h +++ b/src/Git/Git.h @@ -396,7 +396,7 @@ public: CString FixBranchName_Mod(CString& branchName); CString FixBranchName(const CString& branchName); - CString GetLogCmd(const CString& range, const CTGitPath* path, int InfoMask, CFilterData* filter, int logOrderBy); + CString GetLogCmd(CString range, const CTGitPath* path, int InfoMask, CFilterData* filter, int logOrderBy); int GetHash(CGitHash &hash, const CString& friendname); static int GetHash(git_repository * repo, CGitHash &hash, const CString& friendname, bool skipFastCheck = false); diff --git a/test/UnitTests/LogDataVectorTest.cpp b/test/UnitTests/LogDataVectorTest.cpp index fe5eabed9..0ca5fc0b4 100644 --- a/test/UnitTests/LogDataVectorTest.cpp +++ b/test/UnitTests/LogDataVectorTest.cpp @@ -197,10 +197,10 @@ static void ParserFromLogTests() logCache.m_HashMap.clear(); logDataVector.ClearAll(); - EXPECT_EQ(0, logDataVector.ParserFromLog(nullptr, 0, CGit::LOG_INFO_ALL_BRANCH, &range)); - ASSERT_EQ(13, logDataVector.size()); - EXPECT_EQ(13, logDataVector.m_HashMap.size()); - EXPECT_EQ(13, logCache.m_HashMap.size()); + EXPECT_EQ(0, logDataVector.ParserFromLog(nullptr, 0, CGit::LOG_INFO_ALL_BRANCH, &range)); // useless test?, all branches has higher precedence + ASSERT_EQ(23, logDataVector.size()); + EXPECT_EQ(23, logDataVector.m_HashMap.size()); + EXPECT_EQ(23, logCache.m_HashMap.size()); logCache.m_HashMap.clear(); logDataVector.ClearAll(); -- 2.11.4.GIT