Show checkboxes in file list when resolving conflicts in Rebase Dialog
authorSup Yut Sum <ch3cooli@gmail.com>
Tue, 22 Jan 2013 14:40:56 +0000 (22 22:40 +0800)
committerSven Strickroth <email@cs-ware.de>
Thu, 7 Feb 2013 23:35:33 +0000 (8 00:35 +0100)
Only files are automatically selected, submodules are not automatically selected

Signed-off-by: Sup Yut Sum <ch3cooli@gmail.com>
Signed-off-by: Sven Strickroth <email@cs-ware.de>
src/TortoiseProc/CommitDlg.cpp
src/TortoiseProc/RebaseDlg.cpp

index bd501e5..244aaf0 100644 (file)
@@ -573,6 +573,10 @@ void CCommitDlg::OnOK()
        CBlockCacheForPath cacheBlock(g_Git.m_CurrentDir);\r
        DWORD currentTicks = GetTickCount();\r
 \r
+       // ***************************************************\r
+       // ATTENTION: Similar code in RebaseDlg.cpp!!!\r
+       // ***************************************************\r
+\r
        for (int j = 0; j < nListItems; ++j)\r
        {\r
                CTGitPath *entry = (CTGitPath*)m_ListCtrl.GetItemData(j);\r
index b9ffb37..2746bf7 100644 (file)
@@ -33,6 +33,7 @@
 #include "SmartHandle.h"\r
 #include "../TGitCache/CacheInterface.h"\r
 #include "Settings\Settings.h"\r
+#include "MassiveGitTask.h"\r
 \r
 // CRebaseDlg dialog\r
 \r
@@ -1006,6 +1007,7 @@ void CRebaseDlg::OnBnClickedContinue()
                        return ;\r
                m_RebaseStage = REBASE_START;\r
                m_FileListCtrl.Clear();\r
+               m_FileListCtrl.SetHasCheckboxes(false);\r
                m_FileListCtrl.m_CurrentVersion = L"";\r
                m_ctrlTabCtrl.SetTabLabel(REBASE_TAB_CONFLICT, CString(MAKEINTRESOURCE(IDS_PROC_CONFLICTFILES)));\r
                m_ctrlTabCtrl.AddTab(&m_wndOutputRebase, CString(MAKEINTRESOURCE(IDS_LOG)), 2);\r
@@ -1044,10 +1046,63 @@ void CRebaseDlg::OnBnClickedContinue()
                        return;\r
 \r
                GitRev *curRev=(GitRev*)m_CommitList.m_arShownList[m_CurrentRebaseIndex];\r
+               // ***************************************************\r
+               // ATTENTION: Similar code in CommitDlg.cpp!!!\r
+               // ***************************************************\r
+               CMassiveGitTask mgtReAddAfterCommit(_T("add --ignore-errors -f"));\r
+               for (int i = 0; i < m_FileListCtrl.GetItemCount(); i++)\r
+               {\r
+                       CString cmd, out;\r
+                       CTGitPath *entry = (CTGitPath *)m_FileListCtrl.GetItemData(i);\r
+                       if (entry->m_Checked)\r
+                       {\r
+                               if (entry->m_Action & CTGitPath::LOGACTIONS_UNVER)\r
+                                       cmd.Format(_T("git.exe add -f -- \"%s\""), entry->GetGitPathString());\r
+                               else if (entry->m_Action & CTGitPath::LOGACTIONS_DELETED)\r
+                                       cmd.Format(_T("git.exe update-index --force-remove -- \"%s\""), entry->GetGitPathString());\r
+                               else\r
+                                       cmd.Format(_T("git.exe update-index -- \"%s\""), entry->GetGitPathString());\r
+\r
+                               if (g_Git.Run(cmd, &out, CP_UTF8))\r
+                               {\r
+                                       CMessageBox::Show(NULL, out, _T("TortoiseGit"), MB_OK | MB_ICONERROR);\r
+                                       return;\r
+                               }\r
+\r
+                               if (entry->m_Action & CTGitPath::LOGACTIONS_REPLACED)\r
+                                       cmd.Format(_T("git.exe rm -- \"%s\""), entry->GetGitOldPathString());\r
+\r
+                               g_Git.Run(cmd, &out, CP_UTF8);\r
+                       }\r
+                       else\r
+                       {\r
+                               if (entry->m_Action & CTGitPath::LOGACTIONS_ADDED || entry->m_Action & CTGitPath::LOGACTIONS_REPLACED)\r
+                               {\r
+                                       cmd.Format(_T("git.exe rm -f --cache -- \"%s\""), entry->GetGitPathString());\r
+                                       if (g_Git.Run(cmd, &out, CP_UTF8))\r
+                                       {\r
+                                               CMessageBox::Show(NULL, out, _T("TortoiseGit"), MB_OK| MB_ICONERROR);\r
+                                               return;\r
+                                       }\r
+                                       mgtReAddAfterCommit.AddFile(*entry);\r
+\r
+                                       if (entry->m_Action & CTGitPath::LOGACTIONS_REPLACED && !entry->GetGitOldPathString().IsEmpty())\r
+                                       {\r
+                                               cmd.Format(_T("git.exe reset -- \"%s\""), entry->GetGitOldPathString());\r
+                                               g_Git.Run(cmd, &out, CP_UTF8);\r
+                                       }\r
+                               }\r
+                               else if(!(entry->m_Action & CTGitPath::LOGACTIONS_UNVER))\r
+                               {\r
+                                       cmd.Format(_T("git.exe reset -- \"%s\""), entry->GetGitPathString());\r
+                                       g_Git.Run(cmd, &out, CP_UTF8);\r
+                               }\r
+                       }\r
+               }\r
 \r
                CString out =_T("");\r
                CString cmd;\r
-               cmd.Format(_T("git.exe commit -a -C %s"), curRev->m_CommitHash.ToString());\r
+               cmd.Format(_T("git.exe commit -C %s"), curRev->m_CommitHash.ToString());\r
 \r
                AddLogString(cmd);\r
 \r
@@ -1062,6 +1117,13 @@ void CRebaseDlg::OnBnClickedContinue()
                }\r
 \r
                AddLogString(out);\r
+\r
+               if (((DWORD)CRegStdDWORD(_T("Software\\TortoiseGit\\ReaddUnselectedAddedFilesAfterCommit"), TRUE)) == TRUE)\r
+               {\r
+                       BOOL cancel;\r
+                       mgtReAddAfterCommit.Execute(cancel);\r
+               }\r
+\r
                this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_LOG);\r
                if( curRev->GetAction(&m_CommitList) & CTGitPath::LOGACTIONS_REBASE_EDIT)\r
                {\r
@@ -1567,6 +1629,7 @@ int CRebaseDlg::RebaseThread()
 void CRebaseDlg::ListConflictFile()\r
 {\r
        this->m_FileListCtrl.Clear();\r
+       m_FileListCtrl.SetHasCheckboxes(true);\r
        CTGitPathList list;\r
        CTGitPath path;\r
        list.AddPath(path);\r
@@ -1576,6 +1639,8 @@ void CRebaseDlg::ListConflictFile()
        this->m_FileListCtrl.GetStatus(&list,true);\r
        this->m_FileListCtrl.Show(CTGitPath::LOGACTIONS_UNMERGED|CTGitPath::LOGACTIONS_MODIFIED|CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_DELETED,\r
                                                           CTGitPath::LOGACTIONS_UNMERGED);\r
+\r
+       m_FileListCtrl.Check(GITSLC_SHOWFILES);\r
 }\r
 \r
 LRESULT CRebaseDlg::OnRebaseUpdateUI(WPARAM,LPARAM)\r