From: Frank Li Date: Fri, 20 Feb 2009 16:10:02 +0000 (+0800) Subject: Add Combine Commit to one commit at log list dialog X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=commitdiff_plain;h=2b3b98037d04164eb697b0319fd7a1c636812b58 Add Combine Commit to one commit at log list dialog Signed-off-by: Frank Li --- diff --git a/src/TortoiseProc/CommitDlg.cpp b/src/TortoiseProc/CommitDlg.cpp index b2e0879..84220a7 100644 --- a/src/TortoiseProc/CommitDlg.cpp +++ b/src/TortoiseProc/CommitDlg.cpp @@ -57,6 +57,7 @@ CCommitDlg::CCommitDlg(CWnd* pParent /*=NULL*/) , m_itemsCount(0) , m_bSelectFilesForCommit(TRUE) { + this->m_bCommitAmend=FALSE; } CCommitDlg::~CCommitDlg() @@ -284,9 +285,9 @@ BOOL CCommitDlg::OnInitDialog() } err = FALSE; - this->UpdateData(TRUE); - this->m_bCommitAmend=FALSE; - this->UpdateData(FALSE); + //this->UpdateData(TRUE); + //this->m_bCommitAmend=FALSE; + //this->UpdateData(FALSE); return FALSE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE diff --git a/src/TortoiseProc/GitLogListAction.cpp b/src/TortoiseProc/GitLogListAction.cpp index 0b3d003..86bd2cc 100644 --- a/src/TortoiseProc/GitLogListAction.cpp +++ b/src/TortoiseProc/GitLogListAction.cpp @@ -45,6 +45,7 @@ //#include "RepositoryInfo.h" //#include "EditPropertiesDlg.h" #include "FileDiffDlg.h" +#include "CommitDlg.h" IMPLEMENT_DYNAMIC(CGitLogList, CHintListCtrl) @@ -188,6 +189,62 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect) case ID_REBASE_SKIP: SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_SKIP); break; + case ID_COMBINE_COMMIT: + { + CString head; + CString headhash; + + head.Format(_T("HEAD~%d"),LastSelect); + CString hash=g_Git.GetHash(head); + hash=hash.Left(40); + + headhash=g_Git.GetHash(CString(_T("HEAD"))); + headhash=headhash.Left(40); + + GitRev* pLastEntry = reinterpret_cast(m_arShownList.GetAt(LastSelect)); + if(pLastEntry->m_CommitHash != hash) + { + CMessageBox::Show(NULL,_T("Only combine top continuous commit"),_T("TortoiseGit"),MB_OK); + } + if(!g_Git.CheckCleanWorkTree()) + { + CMessageBox::Show(NULL,_T("Combine need clean work tree"),_T("TortoiseGit"),MB_OK); + break; + } + CString cmd,out; + + cmd.Format(_T("git.exe reset --mixed %s"),hash); + if(g_Git.Run(cmd,&out,CP_UTF8)) + { + CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK); + } + CCommitDlg dlg; + for(int i=FirstSelect;i<=LastSelect;i++) + { + GitRev* pRev = reinterpret_cast(m_arShownList.GetAt(i)); + dlg.m_sLogMessage+=pRev->m_Subject+_T("\n")+pRev->m_Body; + dlg.m_sLogMessage+=_T("\n"); + } + dlg.m_bWholeProject=true; + dlg.m_bSelectFilesForCommit = true; + dlg.m_bCommitAmend=true; + dlg.m_AmendStr=dlg.m_sLogMessage; + + if (dlg.DoModal() == IDOK) + { + + }else + { + cmd.Format(_T("git.exe reset --hard %s"),headhash); + out.Empty(); + if(g_Git.Run(cmd,&out,CP_UTF8)) + { + CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK); + } + } + Refresh(); + } + break; default: //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK); break; diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index 3bc63a3..da2078b 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -1133,6 +1133,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARETWO)) popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF); } + if (GetSelectedCount() == 2) { //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME); @@ -1140,6 +1141,20 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF); bAddSeparator = true; } + + if ( IsSelectionContinuous() ) + { + if(m_ContextMenuMask&GetContextMenuBit(ID_COMBINE_COMMIT)) + { + CString head; + head.Format(_T("HEAD~%d"),LastSelect); + CString hash=g_Git.GetHash(head); + hash=hash.Left(40); + GitRev* pLastEntry = reinterpret_cast(m_arShownList.GetAt(LastSelect)); + if(pLastEntry->m_CommitHash == hash) + popup.AppendMenuIcon(ID_COMBINE_COMMIT,_T("Combine to one commit"),IDI_MERGE); + } + } if (m_hasWC) { //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT); diff --git a/src/TortoiseProc/GitLogListBase.h b/src/TortoiseProc/GitLogListBase.h index 659c881..6ed2495 100644 --- a/src/TortoiseProc/GitLogListBase.h +++ b/src/TortoiseProc/GitLogListBase.h @@ -138,6 +138,7 @@ public: ID_REBASE_EDIT, ID_REBASE_SQUASH, ID_REBASE_SKIP, + ID_COMBINE_COMMIT, }; inline unsigned __int64 GetContextMenuBit(int i){ return ((unsigned __int64 )0x1)<