From ed6f6b60a5d815995564286cbc58b0e7a5099619 Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Thu, 13 Feb 2014 00:08:25 +0800 Subject: [PATCH] Can set remote.pushdefault Signed-off-by: Sup Yut Sum --- src/Resources/TortoiseProcENG.rc | 1 + src/TortoiseProc/Settings/SettingGitRemote.cpp | 34 +++++++++++++++++++++++++- src/TortoiseProc/Settings/SettingGitRemote.h | 3 +++ src/TortoiseProc/resource.h | 1 + 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index c021f1d40..926c22981 100644 --- a/src/Resources/TortoiseProcENG.rc +++ b/src/Resources/TortoiseProcENG.rc @@ -1539,6 +1539,7 @@ BEGIN PUSHBUTTON "...",IDC_BUTTON_BROWSE,277,64,16,14 LTEXT "Tags:",IDC_STATIC,101,86,40,8 COMBOBOX IDC_COMBO_TAGOPT,138,85,80,12,CBS_DROPDOWNLIST | WS_TABSTOP + CONTROL "Push Default",IDC_CHECK_PUSHDEFAULT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,225,86,75,10 CONTROL "Prune",IDC_CHECK_PRUNE,"Button",BS_AUTO3STATE | WS_TABSTOP,100,106,35,10 CONTROL "Prune (All remotes)",IDC_CHECK_PRUNEALL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,145,106,90,10 PUSHBUTTON "&Add New/Save",IDC_BUTTON_ADD,100,169,91,14 diff --git a/src/TortoiseProc/Settings/SettingGitRemote.cpp b/src/TortoiseProc/Settings/SettingGitRemote.cpp index eae4f5087..b5d8dc5e5 100644 --- a/src/TortoiseProc/Settings/SettingGitRemote.cpp +++ b/src/TortoiseProc/Settings/SettingGitRemote.cpp @@ -41,6 +41,7 @@ CSettingGitRemote::CSettingGitRemote(CString cmdPath) , m_bNoFetch(false) , m_bPrune(2) , m_bPruneAll(FALSE) + , m_bPushDefault(FALSE) { m_ChangedMask = 0; @@ -60,6 +61,7 @@ void CSettingGitRemote::DoDataExchange(CDataExchange* pDX) DDX_Control(pDX, IDC_COMBO_TAGOPT, m_ctrlTagOpt); DDX_Check(pDX, IDC_CHECK_PRUNE, m_bPrune); DDX_Check(pDX, IDC_CHECK_PRUNEALL, m_bPruneAll); + DDX_Check(pDX, IDC_CHECK_PUSHDEFAULT, m_bPushDefault); } @@ -74,6 +76,7 @@ BEGIN_MESSAGE_MAP(CSettingGitRemote, CPropertyPage) ON_CBN_SELCHANGE(IDC_COMBO_TAGOPT, &CSettingGitRemote::OnCbnSelchangeComboTagOpt) ON_BN_CLICKED(IDC_CHECK_PRUNE, &CSettingGitRemote::OnBnClickedCheckprune) ON_BN_CLICKED(IDC_CHECK_PRUNEALL, &CSettingGitRemote::OnBnClickedCheckpruneall) + ON_BN_CLICKED(IDC_CHECK_PUSHDEFAULT, &CSettingGitRemote::OnBnClickedCheckpushdefault) ON_BN_CLICKED(IDC_BUTTON_REMOVE, &CSettingGitRemote::OnBnClickedButtonRemove) ON_BN_CLICKED(IDC_BUTTON_RENAME_REMOTE, &CSettingGitRemote::OnBnClickedButtonRenameRemote) END_MESSAGE_MAP() @@ -116,6 +119,10 @@ BOOL CSettingGitRemote::OnInitDialog() m_ctrlTagOpt.AddString(CString(MAKEINTRESOURCE(CAppUtils::GetMsysgitVersion() < 0x01090000 ? IDS_FETCH_TAGS_ONLY : IDS_ALL))); m_ctrlTagOpt.SetCurSel(0); + if (CAppUtils::GetMsysgitVersion() < 0x0108030) + { + GetDlgItem(IDC_CHECK_PUSHDEFAULT)->ShowWindow(SW_HIDE); + } if (CAppUtils::GetMsysgitVersion() < 0x0108050) { GetDlgItem(IDC_CHECK_PRUNE)->ShowWindow(SW_HIDE); @@ -179,7 +186,7 @@ void CSettingGitRemote::OnBnClickedButtonAdd() return; } - m_ChangedMask = REMOTE_NAME | REMOTE_URL | REMOTE_PUTTYKEY | REMOTE_TAGOPT | REMOTE_PRUNE | REMOTE_PRUNEALL; + m_ChangedMask = REMOTE_NAME | REMOTE_URL | REMOTE_PUTTYKEY | REMOTE_TAGOPT | REMOTE_PRUNE | REMOTE_PRUNEALL | REMOTE_PUSHDEFAULT; if(IsRemoteExist(m_strRemote)) { CString msg; @@ -255,6 +262,8 @@ void CSettingGitRemote::OnLbnSelchangeListRemote() index = 2; m_ctrlTagOpt.SetCurSel(index); + CString pushDefault = g_Git.GetConfigValue(_T("remote.pushdefault"), CP_UTF8); + m_bPushDefault = pushDefault == remote ? TRUE : FALSE; cmd.Format(_T("remote.%s.prune"), remote); CString prune = g_Git.GetConfigValue(cmd, CP_UTF8); m_bPrune = prune == _T("true") ? TRUE : prune == _T("false") ? FALSE : 2; @@ -337,6 +346,13 @@ void CSettingGitRemote::OnBnClickedCheckpruneall() SetModified(); } +void CSettingGitRemote::OnBnClickedCheckpushdefault() +{ + m_ChangedMask |= REMOTE_PUSHDEFAULT; + UpdateData(); + SetModified(); +} + BOOL CSettingGitRemote::Save(CString key,CString value) { CString cmd,out; @@ -398,6 +414,22 @@ BOOL CSettingGitRemote::OnApply() CWaitCursor wait; this->UpdateData(); + if (m_ChangedMask & REMOTE_PUSHDEFAULT) + { + if (!m_strRemote.Trim().IsEmpty() && m_bPushDefault) + { + if (!SaveGeneral(_T("remote.pushdefault"), m_strRemote.Trim())) + return FALSE; + } + if (!m_bPushDefault) + { + if (!SaveGeneral(_T("remote.pushdefault"), _T(""))) + return FALSE; + } + + m_ChangedMask &= ~REMOTE_PUSHDEFAULT; + } + if (m_ChangedMask & REMOTE_PRUNEALL) { if (!SaveGeneral(_T("fetch.prune"), m_bPruneAll == TRUE ? _T("true") : _T(""))) diff --git a/src/TortoiseProc/Settings/SettingGitRemote.h b/src/TortoiseProc/Settings/SettingGitRemote.h index d770d0ca1..ebdb1a032 100644 --- a/src/TortoiseProc/Settings/SettingGitRemote.h +++ b/src/TortoiseProc/Settings/SettingGitRemote.h @@ -37,6 +37,7 @@ public: REMOTE_TAGOPT =0x8, REMOTE_PRUNE =0x10, REMOTE_PRUNEALL =0x20, + REMOTE_PUSHDEFAULT = 0x40, }; CSettingGitRemote(CString cmdPath); virtual ~CSettingGitRemote(); @@ -61,6 +62,7 @@ protected: afx_msg void OnCbnSelchangeComboTagOpt(); afx_msg void OnBnClickedCheckprune(); afx_msg void OnBnClickedCheckpruneall(); + afx_msg void OnBnClickedCheckpushdefault(); afx_msg void OnBnClickedButtonRemove(); afx_msg void OnBnClickedButtonRenameRemote(); @@ -82,6 +84,7 @@ protected: CString m_strPuttyKeyfile; CComboBox m_ctrlTagOpt; + BOOL m_bPushDefault; BOOL m_bPrune; BOOL m_bPruneAll; }; diff --git a/src/TortoiseProc/resource.h b/src/TortoiseProc/resource.h index e3e633984..4ca021bdd 100644 --- a/src/TortoiseProc/resource.h +++ b/src/TortoiseProc/resource.h @@ -1425,6 +1425,7 @@ #define IDC_CHECK_INHERIT_BTLABEL 1783 #define IDC_CURRENTBRANCH 1784 #define IDC_CHECK_PRUNEALL 1785 +#define IDC_CHECK_PUSHDEFAULT 1786 #define IDC_TESTBUGTRAQREGEXBUTTON 1787 #define IDS_LOG_FILTER_BY 1850 #define IDS_LOG_FILTER_PATHS 1851 -- 2.11.4.GIT