OSDN Git Service

Added extra check in combine process.
authorJohan t Hart <johanthart@gmail.com>
Sun, 22 Feb 2009 13:39:51 +0000 (14:39 +0100)
committerFrank Li <lznuaa@gmail.com>
Sun, 22 Feb 2009 15:47:49 +0000 (23:47 +0800)
Make sure the commits are really continuous.

src/TortoiseProc/GitLogListAction.cpp

index a05fe37..c8fa97c 100644 (file)
@@ -195,19 +195,24 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
                        CString head;\r
                        CString headhash;\r
                        \r
+                       head.Format(_T("HEAD~%d"),FirstSelect);\r
+                       CString hashFirst=g_Git.GetHash(head);\r
+\r
                        head.Format(_T("HEAD~%d"),LastSelect);\r
-                       CString hash=g_Git.GetHash(head);\r
-                       hash=hash.Left(40);\r
+                       CString hashLast=g_Git.GetHash(head);\r
                        \r
                        headhash=g_Git.GetHash(CString(_T("HEAD")));\r
-                       headhash=headhash.Left(40);                     \r
                        \r
                        GitRev* pFirstEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));\r
                        GitRev* pLastEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));\r
-//                     if(pLastEntry->m_CommitHash != hash)\r
-//                     {\r
-//                             CMessageBox::Show(NULL,_T("Only combine top continuous commit"),_T("TortoiseGit"),MB_OK);\r
-//                     }\r
+                       if(pFirstEntry->m_CommitHash != hashFirst || pLastEntry->m_CommitHash != hashLast)\r
+                       {\r
+                               CMessageBox::Show(NULL,_T(\r
+                                       "Cannot combine commits now.\r\n\\r
+                                       Make sure you are viewing the log of your current branch and \\r
+                                       no filters are applied."),_T("TortoiseGit"),MB_OK);\r
+                               break;\r
+                       }\r
                        if(!g_Git.CheckCleanWorkTree())\r
                        {\r
                                CMessageBox::Show(NULL,_T("Combine needs a clean work tree"),_T("TortoiseGit"),MB_OK);\r
@@ -224,7 +229,7 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
                                        CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK);\r
                                        throw std::exception(CUnicodeUtils::GetUTF8(_T("Could not reset to first commit (first step) aborting...\r\n\r\n")+out));\r
                                }\r
-                               cmd.Format(_T("git.exe reset --mixed  %s"),hash);\r
+                               cmd.Format(_T("git.exe reset --mixed  %s"),hashLast);\r
                                if(g_Git.Run(cmd,&out,CP_UTF8))\r
                                {\r
                                        CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK);\r