OSDN Git Service

Git Add Basic Working
authorFrank Li <lznuaa@gmail.com>
Sun, 30 Nov 2008 14:30:58 +0000 (22:30 +0800)
committerFrank Li <lznuaa@gmail.com>
Sun, 30 Nov 2008 14:30:58 +0000 (22:30 +0800)
Git/GitStatusListCtrl.cpp
Git/TGitPath.cpp
Git/TGitPath.h

index ba36ec7..ec48827 100644 (file)
@@ -2849,7 +2849,28 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
                                                                                                                        *filepath,GitRev::GetHead());\r
                                }\r
                                break;\r
-\r
+                       case IDSVNLC_ADD:\r
+                               {       // The add went ok, but we now need to run through the selected items again\r
+                                       // and update their status\r
+                                       POSITION pos = GetFirstSelectedItemPosition();\r
+                                       int index;\r
+                                       while ((index = GetNextSelectedItem(pos)) >= 0)\r
+                                       {\r
+                                               CTGitPath * path=(CTGitPath*)GetItemData(index);\r
+                                               CString cmd;\r
+                                               cmd.Format(_T("git.cmd add %s"),path->GetGitPathString());\r
+                                               CString output;\r
+                                               g_Git.Run(cmd,&output);\r
+                                               path->m_Action = CTGitPath::LOGACTIONS_ADDED;\r
+                                               SetEntryCheck(path,index,true);\r
+                                               SetItemGroup(index,0);\r
+                                               this->m_StatusFileList.AddPath(*path);\r
+                                               this->m_UnRevFileList.RemoveItem(*path);\r
+                                               this->m_IgnoreFileList.RemoveItem(*path);\r
+                                       }\r
+                                       \r
+                               }\r
+                               break;\r
 #if 0\r
                        case IDSVNLC_COPY:\r
                                CopySelectedEntriesToClipboard(0);\r
@@ -4174,6 +4195,8 @@ void CGitStatusListCtrl::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult)
 \r
 void CGitStatusListCtrl::StartDiff(int fileindex)\r
 {\r
+       if(fileindex<0)\r
+               return;\r
        CGitDiff::Diff((CTGitPath*)GetItemData(fileindex),\r
                                CString(GIT_REV_ZERO),\r
                                        GitRev::GetHead());\r
index f4c4cf2..10a7ed7 100644 (file)
@@ -1229,6 +1229,18 @@ void CTGitPathList::RemovePath(const CTGitPath& path)
        }\r
 }\r
 \r
+void CTGitPathList::RemoveItem(CTGitPath & path)\r
+{\r
+       PathVector::iterator it;\r
+       for(it = m_paths.begin(); it != m_paths.end(); ++it)\r
+       {\r
+               if (it->GetGitPathString()==path.GetGitPathString())\r
+               {\r
+                       m_paths.erase(it);\r
+                       return;\r
+               }\r
+       }\r
+}\r
 void CTGitPathList::RemoveChildren()\r
 {\r
        SortByPathname();\r
index 9633243..7ed09a4 100644 (file)
@@ -320,6 +320,7 @@ public:
        /** Removes all paths which are on or in a Subversion admin directory */\r
        void RemoveAdminPaths();\r
        void RemovePath(const CTGitPath& path);\r
+       void RemoveItem(CTGitPath &path);\r
        /** \r
         * Removes all child items and leaves only the top folders. Useful if you\r
         * create the list to remove them (i.e. if you remove a parent folder, the\r