From e285f684531d9d4642e42cc91ad5cab5ceba5ec1 Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Fri, 4 Jul 2014 23:40:15 +0800 Subject: [PATCH] Can pull/fetch with --depth Signed-off-by: Sup Yut Sum --- src/Resources/TortoiseProcENG.rc | 4 +++- src/TortoiseProc/AppUtils.cpp | 9 ++++++++- src/TortoiseProc/PullFetchDlg.cpp | 14 ++++++++++++++ src/TortoiseProc/PullFetchDlg.h | 3 +++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index 508a7fe94..2558184d3 100644 --- a/src/Resources/TortoiseProcENG.rc +++ b/src/Resources/TortoiseProcENG.rc @@ -1115,7 +1115,9 @@ BEGIN PUSHBUTTON "...",IDC_BUTTON_BROWSE_REF,302,65,14,14 CONTROL "&Squash",IDC_CHECK_SQUASH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,100,107,10 CONTROL "No &Fast Forward",IDC_CHECK_NOFF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,116,110,10 - CONTROL "No Co&mmit",IDC_CHECK_NOCOMMIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,132,100,161,10 + CONTROL "No Co&mmit",IDC_CHECK_NOCOMMIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,132,100,100,10 + CONTROL "depth ",IDC_CHECK_DEPTH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,234,100,43,10 + EDITTEXT IDC_EDIT_DEPTH,278,100,32,14,ES_AUTOHSCROLL | ES_NUMBER CONTROL "Fast Forward o&nly",IDC_CHECK_FFONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,132,117,160,10 CONTROL "Tags",IDC_CHECK_FETCHTAGS,"Button",BS_AUTO3STATE | WS_TABSTOP,19,133,110,10 LTEXT "",IDC_STATIC_TAGOPT,132,133,80,8 diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index 2b1c3017c..0b917aeac 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -2208,6 +2208,7 @@ bool CAppUtils::Pull(bool showPush) CString ffonly; CString squash; CString nocommit; + CString depth; CString notags; CString prune; @@ -2229,6 +2230,9 @@ bool CAppUtils::Pull(bool showPush) if (dlg.m_bNoCommit) nocommit = _T("--no-commit"); + if (dlg.m_bDepth) + depth.Format(_T("--depth %d "), dlg.m_nDepth); + int ver = CAppUtils::GetMsysgitVersion(); if (dlg.m_bPrune == TRUE) @@ -2239,7 +2243,7 @@ bool CAppUtils::Pull(bool showPush) if(ver >= 0x01070203) //above 1.7.0.2 cmdRebase += _T("--progress "); - cmd.Format(_T("git.exe pull -v %s %s %s %s %s %s %s \"%s\" %s"), cmdRebase, noff, ffonly, squash, nocommit, notags, prune, url, dlg.m_RemoteBranchName); + cmd.Format(_T("git.exe pull -v %s %s %s %s %s %s %s %s \"%s\" %s"), cmdRebase, noff, ffonly, squash, nocommit, depth, notags, prune, url, dlg.m_RemoteBranchName); CProgressDlg progress; progress.m_GitCmd = cmd; progress.m_PostCmdList.Add(CString(MAKEINTRESOURCE(IDS_PROC_PULL_DIFFS))); @@ -2352,6 +2356,9 @@ bool CAppUtils::Fetch(CString remoteName, bool allowRebase, bool allRemotes) if(ver >= 0x01070203) //above 1.7.0.2 arg = _T("--progress "); + if (dlg.m_bDepth) + arg.AppendFormat(_T("--depth %d "), dlg.m_nDepth); + if (dlg.m_bPrune == TRUE) arg += _T("--prune "); else if (dlg.m_bPrune == FALSE && ver >= 0x01080500) diff --git a/src/TortoiseProc/PullFetchDlg.cpp b/src/TortoiseProc/PullFetchDlg.cpp index 9adde056d..ea76f2a55 100644 --- a/src/TortoiseProc/PullFetchDlg.cpp +++ b/src/TortoiseProc/PullFetchDlg.cpp @@ -42,6 +42,8 @@ CPullFetchDlg::CPullFetchDlg(CWnd* pParent /*=NULL*/) m_bRebase = FALSE; m_bSquash = false; m_bNoCommit = false; + m_nDepth = 1; + m_bDepth = FALSE; m_bFFonly = false; m_bFetchTags = 2; m_bAllRemotes = FALSE; @@ -65,6 +67,8 @@ void CPullFetchDlg::DoDataExchange(CDataExchange* pDX) DDX_Check(pDX,IDC_PUTTYKEY_AUTOLOAD,m_bAutoLoad); DDX_Check(pDX,IDC_CHECK_REBASE,m_bRebase); DDX_Check(pDX,IDC_CHECK_PRUNE,m_bPrune); + DDX_Check(pDX, IDC_CHECK_DEPTH, m_bDepth); + DDX_Text(pDX, IDC_EDIT_DEPTH, m_nDepth); DDX_Check(pDX, IDC_CHECK_FFONLY, m_bFFonly); DDX_Check(pDX, IDC_CHECK_FETCHTAGS, m_bFetchTags); } @@ -77,6 +81,7 @@ BEGIN_MESSAGE_MAP(CPullFetchDlg, CHorizontalResizableStandAloneDialog) ON_BN_CLICKED(IDOK, &CPullFetchDlg::OnBnClickedOk) ON_STN_CLICKED(IDC_REMOTE_MANAGE, &CPullFetchDlg::OnStnClickedRemoteManage) ON_BN_CLICKED(IDC_BUTTON_BROWSE_REF, &CPullFetchDlg::OnBnClickedButtonBrowseRef) + ON_BN_CLICKED(IDC_CHECK_DEPTH, OnBnClickedCheckDepth) ON_BN_CLICKED(IDC_CHECK_FFONLY, OnBnClickedCheckFfonly) ON_BN_CLICKED(IDC_CHECK_NOFF, OnBnClickedCheckFfonly) END_MESSAGE_MAP() @@ -106,6 +111,7 @@ BOOL CPullFetchDlg::OnInitDialog() AdjustControlSize(IDC_OTHER_RD); AdjustControlSize(IDC_CHECK_SQUASH); AdjustControlSize(IDC_CHECK_NOCOMMIT); + AdjustControlSize(IDC_CHECK_DEPTH); AdjustControlSize(IDC_CHECK_NOFF); AdjustControlSize(IDC_CHECK_FFONLY); AdjustControlSize(IDC_CHECK_FETCHTAGS); @@ -177,6 +183,8 @@ BOOL CPullFetchDlg::OnInitDialog() if (g_GitAdminDir.IsBareRepo(g_Git.m_CurrentDir)) this->GetDlgItem(IDC_CHECK_REBASE)->EnableWindow(FALSE); + OnBnClickedCheckDepth(); + m_Other.SetCaseSensitive(TRUE); m_Other.SetURLHistory(TRUE); m_Other.LoadHistory(_T("Software\\TortoiseGit\\History\\PullURLS"), _T("url")); @@ -378,6 +386,12 @@ void CPullFetchDlg::OnBnClickedButtonBrowseRef() CheckRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD,IDC_REMOTE_RD); } +void CPullFetchDlg::OnBnClickedCheckDepth() +{ + UpdateData(TRUE); + GetDlgItem(IDC_EDIT_DEPTH)->EnableWindow(m_bDepth); +} + void CPullFetchDlg::OnBnClickedCheckFfonly() { UpdateData(); diff --git a/src/TortoiseProc/PullFetchDlg.h b/src/TortoiseProc/PullFetchDlg.h index 02a08cdb2..8545affa1 100644 --- a/src/TortoiseProc/PullFetchDlg.h +++ b/src/TortoiseProc/PullFetchDlg.h @@ -59,6 +59,8 @@ public: BOOL m_bFFonly; BOOL m_bFetchTags; BOOL m_bNoCommit; + BOOL m_bDepth; + int m_nDepth; BOOL m_bAutoLoadEnable; BOOL m_bAllRemotes; CString m_PreSelectRemote; @@ -78,6 +80,7 @@ protected: void Refresh(); afx_msg void OnStnClickedRemoteManage(); afx_msg void OnBnClickedButtonBrowseRef(); + afx_msg void OnBnClickedCheckDepth(); afx_msg void OnBnClickedCheckFetchtags(); afx_msg void OnBnClickedCheckFfonly(); }; -- 2.11.4.GIT