OSDN Git Service

Issue 20: Add To Ignore from Commit dialog not working
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / AppUtils.cpp
index b616560..d9d5815 100644 (file)
@@ -1156,35 +1156,58 @@ bool CAppUtils::Switch(CString *CommitHash)
        return FALSE;\r
 }\r
 \r
-bool CAppUtils::IgnoreFile(CTGitPath &path,bool IsMask)\r
+bool CAppUtils::IgnoreFile(CTGitPathList &path,bool IsMask)\r
 {\r
        CString ignorefile;\r
-       ignorefile=g_Git.m_CurrentDir;\r
-       ignorefile+=path.GetDirectory().GetWinPathString()+_T("\\.gitignore");\r
+       ignorefile=g_Git.m_CurrentDir+_T("\\");\r
+\r
+       if(IsMask)\r
+       {\r
+               ignorefile+=path.GetCommonRoot().GetWinPathString()+_T("\\.gitignore");\r
+\r
+       }else\r
+       {\r
+               ignorefile+=_T("\\.gitignore");\r
+       }\r
 \r
        CStdioFile file;\r
-       if(!file.Open(ignorefile,CFile::modeCreate|CFile::modeWrite))\r
+       if(!file.Open(ignorefile,CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate))\r
        {\r
                CMessageBox::Show(NULL,ignorefile+_T(" Open Failure"),_T("TortoiseGit"),MB_OK);\r
                return FALSE;\r
        }\r
 \r
        CString ignorelist;\r
-       file.ReadString(ignorelist);\r
-\r
-       if(IsMask)\r
+       try\r
        {\r
-               ignorelist+=_T("\n*.")+path.GetFileExtension();\r
-       }else\r
+               //file.ReadString(ignorelist);\r
+               file.SeekToEnd();\r
+\r
+               for(int i=0;i<path.GetCount();i++)\r
+               {\r
+                       if(IsMask)\r
+                       {\r
+                               ignorelist+=_T("\n*")+path[i].GetFileExtension();\r
+                               break;\r
+                       }else\r
+                       {\r
+                               ignorelist+=_T("\n/")+path[i].GetGitPathString();\r
+                       }\r
+               }\r
+               file.WriteString(ignorelist);\r
+\r
+               file.Close();\r
+\r
+       }catch(...)\r
        {\r
-               ignorelist+=_T("\n")+path.GetBaseFilename();\r
+               file.Close();\r
+               return FALSE;\r
        }\r
-       file.WriteString(ignorelist);\r
-\r
-       file.Close();\r
+       \r
        return TRUE;\r
 }\r
 \r
+\r
 bool CAppUtils::GitReset(CString *CommitHash,int type)\r
 {\r
        CResetDlg dlg;\r