From 064c23a091c76eebccf572d2a8542dfeaf9b744d Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Tue, 28 Aug 2012 20:48:56 +0200 Subject: [PATCH] GitStatusListCtrl: Added skip worktree Signed-off-by: Sven Strickroth --- src/Git/GitStatusListCtrl.cpp | 30 ++++++++++++++++++++++++++++++ src/Git/GitStatusListCtrl.h | 2 ++ src/Resources/TortoiseProcENG.rc | 1 + src/TortoiseProc/resource.h | 1 + 4 files changed, 34 insertions(+) diff --git a/src/Git/GitStatusListCtrl.cpp b/src/Git/GitStatusListCtrl.cpp index 96b01d248..7b2feee61 100644 --- a/src/Git/GitStatusListCtrl.cpp +++ b/src/Git/GitStatusListCtrl.cpp @@ -1654,6 +1654,11 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) popup.AppendMenuIcon(IDGITLC_REVERT, IDS_MENUREVERT, IDI_REVERT); } + if ((m_dwContextMenus & GITSLC_POPSKIPWORKTREE) && (this->m_CurrentVersion.IsEmpty() || this->m_CurrentVersion == GIT_REV_ZERO) && !(wcStatus & (CTGitPath::LOGACTIONS_ADDED | CTGitPath::LOGACTIONS_DELETED | CTGitPath::LOGACTIONS_UNMERGED)) && !filepath->IsDirectory()) + { + popup.AppendMenuIcon(IDGITLC_SKIPWORKTREE, IDS_STATUSLIST_SKIPWORKTREE); + } + if ((m_dwContextMenus & GITSLC_POPASSUMEVALID) && (this->m_CurrentVersion.IsEmpty() || this->m_CurrentVersion == GIT_REV_ZERO) && !(wcStatus & (CTGitPath::LOGACTIONS_ADDED | CTGitPath::LOGACTIONS_DELETED | CTGitPath::LOGACTIONS_UNMERGED)) && !filepath->IsDirectory()) { popup.AppendMenuIcon(IDGITLC_ASSUMEVALID, IDS_MENUASSUMEVALID); @@ -2358,7 +2363,32 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) SetRedraw(TRUE); } break; + case IDGITLC_SKIPWORKTREE: + { + CString cmdTemplate; + cmdTemplate = _T("git.exe update-index --skip-worktree \"%s\""); + POSITION pos = GetFirstSelectedItemPosition(); + int index = -1; + while ((index = GetNextSelectedItem(pos)) >= 0) + { + CTGitPath * path = (CTGitPath *)GetItemData(index); + ASSERT(path); + if(path == NULL) + continue; + CString cmd, output; + cmd.Format(cmdTemplate, path->GetGitPathString()); + if (g_Git.Run(cmd, &output, CP_UTF8)) + { + MessageBox(output, _T("TortoiseGit"), MB_ICONERROR); + } + } + if (NULL != GetParent() && NULL != GetParent()->GetSafeHwnd()) + GetParent()->SendMessage(GITSLNM_NEEDSREFRESH); + + SetRedraw(TRUE); + } + break; case IDGITLC_COPY: CopySelectedEntriesToClipboard(0); break; diff --git a/src/Git/GitStatusListCtrl.h b/src/Git/GitStatusListCtrl.h index e38507108..2261c16f4 100644 --- a/src/Git/GitStatusListCtrl.h +++ b/src/Git/GitStatusListCtrl.h @@ -125,6 +125,7 @@ GITSLC_SHOWINCOMPLETE|GITSLC_SHOWEXTERNAL|GITSLC_SHOWINEXTERNALS) #define GITSLC_POPCOMPARETWOFILES CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_COMPARETWO) #define GITSLC_POPRESTORE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_POPRESTORE) #define GITSLC_POPASSUMEVALID CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_ASSUMEVALID) +#define GITSLC_POPSKIPWORKTREE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_SKIPWORKTREE) #define GITSLC_IGNORECHANGELIST _T("ignore-on-commit") @@ -516,6 +517,7 @@ public: IDGITLC_CREATERESTORE , IDGITLC_RESTOREPATH , IDGITLC_ASSUMEVALID , + IDGITLC_SKIPWORKTREE , // the IDSVNLC_MOVETOCS *must* be the last index, because it contains a dynamic submenu where // the submenu items get command ID's sequent to this number IDGITLC_MOVETOCS , diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index 0cfc9f125..0815e2dad 100644 --- a/src/Resources/TortoiseProcENG.rc +++ b/src/Resources/TortoiseProcENG.rc @@ -2763,6 +2763,7 @@ BEGIN IDS_CHSTAT_FILECOL "File" IDS_CHSTAT_WCCOL "Local status" IDS_CHSTAT_REPOCOL "Remote status" + IDS_STATUSLIST_SKIPWORKTREE "Skip worktree" IDS_SETTINGS_BUGTRAQ_PATHCOL "Path" IDS_SETTINGS_BUGTRAQ_PROVIDERCOL "Provider" IDS_SETTINGS_BUGTRAQ_PARAMETERSCOL "Parameters" diff --git a/src/TortoiseProc/resource.h b/src/TortoiseProc/resource.h index 8f7f031f6..d786210d5 100644 --- a/src/TortoiseProc/resource.h +++ b/src/TortoiseProc/resource.h @@ -155,6 +155,7 @@ #define IDS_CHSTAT_WCCOL 1001 #define IDS_CHSTAT_REPOCOL 1002 #define IDC_LOGLIST 1003 +#define IDS_STATUSLIST_SKIPWORKTREE 1003 #define IDC_PASSEDIT 1004 #define IDS_SETTINGS_BUGTRAQ_PATHCOL 1004 #define IDC_INFOTEXT 1005 -- 2.11.4.GIT