From 617257855e26845e8f40b266fe8ea91fca3d6b4f Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Sun, 3 Jan 2016 11:33:08 +0800 Subject: [PATCH] Fixed issue #2678: Filter out special ref names in log graph Signed-off-by: Sup Yut Sum --- Languages/Tortoise.pot | 8 +++++ src/Changelog.txt | 1 + src/Git/Git.cpp | 11 ++++++- src/Git/Git.h | 3 +- src/Resources/TortoiseProcENG.rc | 2 ++ src/TortoiseProc/GitLogListBase.cpp | 8 ++--- src/TortoiseProc/LogDlg.cpp | 58 ++++++++++++++++++++++++++++++------- src/TortoiseProc/LogDlg.h | 13 +++++++-- src/TortoiseProc/resource.h | 2 ++ 9 files changed, 87 insertions(+), 19 deletions(-) diff --git a/Languages/Tortoise.pot b/Languages/Tortoise.pot index 80bf82fc0..a14cb982f 100644 --- a/Languages/Tortoise.pot +++ b/Languages/Tortoise.pot @@ -1475,6 +1475,10 @@ msgstr "" msgid "" msgstr "" +#. Resource IDs: (IDS_PROC_LOG_BASIC_REFS) +msgid "" +msgstr "" + #. Resource IDs: (IDS_PROC_LOG_LOCAL_BRANCHES) msgid "" msgstr "" @@ -1812,6 +1816,10 @@ msgstr "" msgid "All Parents" msgstr "" +#. Resource IDs: (IDS_PROC_LOG_SELECT_BASIC_REFS) +msgid "All basic refs" +msgstr "" + #. Resource IDs: (IDS_PROC_LOG_SELECT_LOCAL_BRANCHES) msgid "All local branches" msgstr "" diff --git a/src/Changelog.txt b/src/Changelog.txt index 65c1332cb..2dad867f8 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -23,6 +23,7 @@ Released: unreleased * Fixed issue #2270: Print a warning on a merge commit, so that changes are not unchecked unintentionally * Fixed issue #2310: Add support for notes.rewrite.rebase * Fixed issue #2629: "Browse References Dialog" save sort column + order + * Fixed issue #2678: Filter out special ref names in log graph == Bug Fixes == * Fixed issue #2647: TortoiseGitBlame does not display files correctly with mixed line endings (such as CRCRLF) diff --git a/src/Git/Git.cpp b/src/Git/Git.cpp index 159885dce..f4c66f3fa 100644 --- a/src/Git/Git.cpp +++ b/src/Git/Git.cpp @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2015 - TortoiseGit +// Copyright (C) 2008-2016 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -947,6 +947,15 @@ CString CGit::GetLogCmd(const CString& range, const CTGitPath* path, int mask, if(mask& CGit::LOG_INFO_ALL_BRANCH) param += _T(" --all"); + if (mask& CGit::LOG_INFO_BASIC_REFS) + { + param += _T(" --branches"); + param += _T(" --tags"); + param += _T(" --remotes"); + param += _T(" --glob=stas[h]"); // require at least one glob operator + param += _T(" --glob=bisect"); + } + if(mask & CGit::LOG_INFO_LOCAL_BRANCHES) param += _T(" --branches"); diff --git a/src/Git/Git.h b/src/Git/Git.h index cab0f36da..b134dd85b 100644 --- a/src/Git/Git.h +++ b/src/Git/Git.h @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2015 - TortoiseGit +// Copyright (C) 2008-2016 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -335,6 +335,7 @@ public: LOG_INFO_FULL_DIFF = 0x2000, LOG_INFO_SIMPILFY_BY_DECORATION = 0x4000, LOG_INFO_LOCAL_BRANCHES = 0x8000, + LOG_INFO_BASIC_REFS = 0x10000, }LOG_INFO_MASK; typedef enum diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index 8cbbabdb0..660897eb6 100644 --- a/src/Resources/TortoiseProcENG.rc +++ b/src/Resources/TortoiseProcENG.rc @@ -4733,6 +4733,8 @@ BEGIN IDS_COMMIT_MERGE_HINT "The commit you are composing is a special commit. It is a merge commit and, thus contains your changes as well as the changes of a merged branch.\n\nYou should NOT uncheck files unless you know what you are doing.\n\nWhile merging conflicts can occur which need to be resolved manually (i.e., integrate your changes into a file which was also modified on another branch).\n\nSee help for more information." IDS_REBASE_PRESERVEMERGES_TT "This preserves merge commits, however, it has known bugs as re-ordering commits is not working properly (same limitation as for vanilla git rebase), see help." + IDS_PROC_LOG_BASIC_REFS "" + IDS_PROC_LOG_SELECT_BASIC_REFS "All basic refs" END #endif // English (U.S.) resources diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index a4d8f1601..b750c83fd 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2015 - TortoiseGit +// Copyright (C) 2008-2016 - TortoiseGit // Copyright (C) 2005-2007 Marco Costalba // This program is free software; you can redistribute it and/or @@ -2723,7 +2723,7 @@ int CGitLogListBase::BeginFetchLog() mask &= ~CGit::LOG_INFO_FOLLOW; // follow does not work with all branches 8at least in TGit) if (mask & CGit::LOG_INFO_FOLLOW) - mask &= ~CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_LOCAL_BRANCHES; + mask &= ~(CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_BASIC_REFS | CGit::LOG_INFO_LOCAL_BRANCHES); CString cmd = g_Git.GetLogCmd(m_sRange, path, mask, &m_Filter); @@ -2750,7 +2750,7 @@ int CGitLogListBase::BeginFetchLog() if (!g_Git.CanParseRev(m_sRange)) { - if (!(mask & CGit::LOG_INFO_ALL_BRANCH) && !(mask & CGit::LOG_INFO_LOCAL_BRANCHES)) + if (!(mask & CGit::LOG_INFO_ALL_BRANCH) && !(mask & CGit::LOG_INFO_BASIC_REFS) && !(mask & CGit::LOG_INFO_LOCAL_BRANCHES)) return 0; // if show all branches, pick any ref as dummy entry ref @@ -2912,7 +2912,7 @@ UINT CGitLogListBase::LogThread() if (!g_Git.CanParseRev(m_sRange)) { // walk revisions if show all branches and there exists any ref - if (!(m_ShowMask & CGit::LOG_INFO_ALL_BRANCH) && !(m_ShowMask & CGit::LOG_INFO_LOCAL_BRANCHES)) + if (!(m_ShowMask & CGit::LOG_INFO_ALL_BRANCH) && !(m_ShowMask & CGit::LOG_INFO_BASIC_REFS) && !(m_ShowMask & CGit::LOG_INFO_LOCAL_BRANCHES)) shouldWalk = false; else { diff --git a/src/TortoiseProc/LogDlg.cpp b/src/TortoiseProc/LogDlg.cpp index 0bc85689f..fd2e3d9b5 100644 --- a/src/TortoiseProc/LogDlg.cpp +++ b/src/TortoiseProc/LogDlg.cpp @@ -1,7 +1,7 @@ // TortoiseGit - a Windows shell extension for easy version control // Copyright (C) 2003-2009, 2015 - TortoiseSVN -// Copyright (C) 2008-2015 - TortoiseGit +// Copyright (C) 2008-2016 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -75,7 +75,18 @@ CLogDlg::CLogDlg(CWnd* pParent /*=NULL*/) m_regbAllBranch=CRegDWORD(str,FALSE); - m_bAllBranch=m_regbAllBranch; + m_AllBranchType = (AllBranchType)(DWORD)m_regbAllBranch; + switch (m_AllBranchType) + { + case AllBranchType::None: + m_bAllBranch = FALSE; + break; + case AllBranchType::AllBranches: + m_bAllBranch = TRUE; + break; + default: + m_bAllBranch = BST_INDETERMINATE; + } str = g_Git.m_CurrentDir; str.Replace(_T(":"),_T("_")); @@ -100,7 +111,7 @@ CLogDlg::CLogDlg(CWnd* pParent /*=NULL*/) CLogDlg::~CLogDlg() { - m_regbAllBranch = m_bAllBranch; + m_regbAllBranch = (DWORD)m_AllBranchType; m_regbShowTags = m_bShowTags; m_regbShowLocalBranches = m_bShowLocalBranches; m_regbShowRemoteBranches = m_bShowRemoteBranches; @@ -213,7 +224,10 @@ void CLogDlg::SetParams(const CTGitPath& orgPath, const CTGitPath& path, CString range = _T("HEAD"); if (!(range.IsEmpty() || range == _T("HEAD"))) + { m_bAllBranch = BST_UNCHECKED; + m_AllBranchType = AllBranchType::None; + } SetRange(range); @@ -321,10 +335,12 @@ BOOL CLogDlg::OnInitDialog() SetFilterCueText(); m_LogList.m_ShowMask &= ~CGit::LOG_INFO_LOCAL_BRANCHES; - if (m_bAllBranch == BST_CHECKED) + if (m_AllBranchType == AllBranchType::AllBranches) m_LogList.m_ShowMask|=CGit::LOG_INFO_ALL_BRANCH; - else if (m_bAllBranch == BST_INDETERMINATE) + else if (m_AllBranchType == AllBranchType::AllLocalBranches) m_LogList.m_ShowMask |= CGit::LOG_INFO_LOCAL_BRANCHES; + else if (m_AllBranchType == AllBranchType::AllBasicRefs) + m_LogList.m_ShowMask |= CGit::LOG_INFO_BASIC_REFS; else m_LogList.m_ShowMask&=~CGit::LOG_INFO_ALL_BRANCH; @@ -1290,6 +1306,8 @@ void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point) popup.EnableMenuItem(cnt, fetchHead.IsEmpty()); popup.AppendMenuIcon(++cnt, IDS_ALL); popup.EnableMenuItem(cnt, m_bFollowRenames); + popup.AppendMenuIcon(++cnt, IDS_PROC_LOG_SELECT_BASIC_REFS); + popup.EnableMenuItem(cnt, m_bFollowRenames); popup.AppendMenuIcon(++cnt, IDS_PROC_LOG_SELECT_LOCAL_BRANCHES); popup.EnableMenuItem(cnt, m_bFollowRenames); int offset = ++cnt; @@ -1314,8 +1332,9 @@ void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point) return; } - m_LogList.m_ShowMask &= ~(CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_LOCAL_BRANCHES); + m_LogList.m_ShowMask &= ~(CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_BASIC_REFS | CGit::LOG_INFO_LOCAL_BRANCHES); m_bAllBranch = BST_UNCHECKED; + m_AllBranchType = AllBranchType::None; if (cmd == 2) { SetRange(g_Git.GetCurrentBranch(true)); @@ -1327,11 +1346,19 @@ void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point) else if (cmd == 4) { m_bAllBranch = BST_CHECKED; + m_AllBranchType = AllBranchType::AllBranches; m_LogList.m_ShowMask |= CGit::LOG_INFO_ALL_BRANCH; } else if (cmd == 5) { m_bAllBranch = BST_INDETERMINATE; + m_AllBranchType = AllBranchType::AllBasicRefs; + m_LogList.m_ShowMask |= CGit::LOG_INFO_BASIC_REFS; + } + else if (cmd == 6) + { + m_bAllBranch = BST_INDETERMINATE; + m_AllBranchType = AllBranchType::AllLocalBranches; m_LogList.m_ShowMask |= CGit::LOG_INFO_LOCAL_BRANCHES; } else if (cmd >= offset) @@ -2967,22 +2994,24 @@ void CLogDlg::OnBnClickedAllBranch() { // m_bAllBranch is not auto-toggled by MFC, we have to handle it manually (in order to prevent the indeterminate state) - m_LogList.m_ShowMask &=~ (CGit::LOG_INFO_LOCAL_BRANCHES | CGit::LOG_INFO_ALL_BRANCH); + m_LogList.m_ShowMask &=~ (CGit::LOG_INFO_LOCAL_BRANCHES | CGit::LOG_INFO_BASIC_REFS | CGit::LOG_INFO_ALL_BRANCH); if (m_bAllBranch) { m_bAllBranch = BST_UNCHECKED; + m_AllBranchType = AllBranchType::None; m_ChangedFileListCtrl.m_sDisplayedBranch = m_LogList.GetRange(); } else { m_bAllBranch = BST_CHECKED; + m_AllBranchType = AllBranchType::AllBranches; m_LogList.m_ShowMask|=CGit::LOG_INFO_ALL_BRANCH; m_ChangedFileListCtrl.m_sDisplayedBranch.Empty(); } // need to save value here, so that log dialogs started from now on also have AllBranch activated - m_regbAllBranch = m_bAllBranch; + m_regbAllBranch = (DWORD)m_AllBranchType; UpdateData(FALSE); @@ -2997,10 +3026,12 @@ void CLogDlg::OnBnClickedFollowRenames() { m_LogList.m_ShowMask |= CGit::LOG_INFO_FOLLOW; m_LogList.m_ShowMask &=~ CGit::LOG_INFO_LOCAL_BRANCHES; + m_LogList.m_ShowMask &= ~CGit::LOG_INFO_BASIC_REFS; if (m_bAllBranch) { m_bAllBranch = FALSE; + m_AllBranchType = AllBranchType::None; m_LogList.m_ShowMask &=~ CGit::LOG_INFO_ALL_BRANCH; } @@ -3062,8 +3093,9 @@ void CLogDlg::OnBnClickedBrowseRef() SetRange(newRef); - m_LogList.m_ShowMask &= ~(CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_LOCAL_BRANCHES); + m_LogList.m_ShowMask &= ~(CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_BASIC_REFS | CGit::LOG_INFO_LOCAL_BRANCHES); m_bAllBranch = BST_UNCHECKED; + m_AllBranchType = AllBranchType::None; UpdateData(FALSE); OnRefresh(); @@ -3075,14 +3107,18 @@ void CLogDlg::ShowStartRef() //Show ref name on top if(!::IsWindow(m_hWnd)) return; - if (m_LogList.m_ShowMask & (CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_LOCAL_BRANCHES)) + if (m_LogList.m_ShowMask & (CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_BASIC_REFS | CGit::LOG_INFO_LOCAL_BRANCHES)) { - switch (m_LogList.m_ShowMask & (CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_LOCAL_BRANCHES)) + switch (m_LogList.m_ShowMask & (CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_BASIC_REFS | CGit::LOG_INFO_LOCAL_BRANCHES)) { case CGit::LOG_INFO_ALL_BRANCH: m_staticRef.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_LOG_ALLBRANCHES))); break; + case CGit::LOG_INFO_BASIC_REFS: + m_staticRef.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_LOG_BASIC_REFS))); + break; + case CGit::LOG_INFO_LOCAL_BRANCHES: m_staticRef.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_LOG_LOCAL_BRANCHES))); break; diff --git a/src/TortoiseProc/LogDlg.h b/src/TortoiseProc/LogDlg.h index 2da55d373..a65ac80f9 100644 --- a/src/TortoiseProc/LogDlg.h +++ b/src/TortoiseProc/LogDlg.h @@ -1,7 +1,7 @@ // TortoiseGit - a Windows shell extension for easy version control // Copyright (C) 2003-2009 - TortoiseSVN -// Copyright (C) 2008-2015 - TortoiseGit +// Copyright (C) 2008-2016 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -46,6 +46,14 @@ typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2); +enum AllBranchType +{ + None = 0, + AllBranches = 1, + AllLocalBranches = 2, + AllBasicRefs = 3, +}; + /** * \ingroup TortoiseProc * Shows log messages of a single file or folder in a listbox. @@ -226,7 +234,8 @@ private: BOOL m_iHidePaths; bool m_bFirstParent; - BOOL m_bAllBranch; + BOOL m_bAllBranch; // variable for checkbox only + AllBranchType m_AllBranchType; // variable for actual branch type BOOL m_bWholeProject; bool m_bFollowRenames; BOOL m_bShowUnversioned; diff --git a/src/TortoiseProc/resource.h b/src/TortoiseProc/resource.h index c02146923..0644a558d 100644 --- a/src/TortoiseProc/resource.h +++ b/src/TortoiseProc/resource.h @@ -1246,8 +1246,10 @@ #define IDS_REBASE_PRESERVEMERGES_TT 1587 #define IDD_REFLOG 1588 #define IDC_TREE_REF 1588 +#define IDS_PROC_LOG_BASIC_REFS 1588 #define IDD_SUBMODULE_ADD 1589 #define IDC_EDIT_NAME 1589 +#define IDS_PROC_LOG_SELECT_BASIC_REFS 1589 #define IDC_BUGTRAQ_WARNINGIFNOISSUE 1593 #define IDC_BUGTRAQ_APPEND 1594 #define IDC_WARN_NO_SIGNED_OFF_BY 1594 -- 2.11.4.GIT