From b43d16fc5ad2b4caca4b11d2d85fb2be0643b6dd Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Mon, 3 Aug 2015 21:35:35 +0800 Subject: [PATCH] Can use libgit2 to add an unregistered submodule to index Signed-off-by: Sup Yut Sum --- ext/libgit2 | 2 +- src/TortoiseProc/CommitDlg.cpp | 20 ++------------------ .../ProgressCommands/AddProgressCommand.cpp | 3 ++- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/ext/libgit2 b/ext/libgit2 index 4e0421fdb..69adb781e 160000 --- a/ext/libgit2 +++ b/ext/libgit2 @@ -1 +1 @@ -Subproject commit 4e0421fdbdd54004041797b5dd5e79597c86f447 +Subproject commit 69adb781e17f77b19d66613ad7e52c38d6ac64e1 diff --git a/src/TortoiseProc/CommitDlg.cpp b/src/TortoiseProc/CommitDlg.cpp index 77f00b1c3..bce89b270 100644 --- a/src/TortoiseProc/CommitDlg.cpp +++ b/src/TortoiseProc/CommitDlg.cpp @@ -744,27 +744,11 @@ void CCommitDlg::OnOK() } } - CStringA filePathA = CUnicodeUtils::GetMulti(entry->GetGitPathString(), CP_UTF8); + CStringA filePathA = CUnicodeUtils::GetMulti(entry->GetGitPathString(), CP_UTF8).TrimRight(_T('/')); if (entry->m_Checked && !m_bCommitMessageOnly) { - if (entry->IsDirectory()) - { - CAutoSubmodule submodule; - if (git_submodule_lookup(submodule.GetPointer(), repository, filePathA)) - { - bAddSuccess = false; - CMessageBox::Show(m_hWnd, CGit::GetLibGit2LastErr(_T("Could not open submodule \"") + entry->GetGitPathString() + _T("\".")), _T("TortoiseGit"), MB_OK | MB_ICONERROR); - break; - } - if (git_submodule_add_to_index(submodule, FALSE)) - { - bAddSuccess = false; - CMessageBox::Show(m_hWnd, CGit::GetLibGit2LastErr(_T("Could not add submodule \"") + entry->GetGitPathString() + _T("\" to index.")), _T("TortoiseGit"), MB_OK | MB_ICONERROR); - break; - } - } - else if (entry->m_Action & CTGitPath::LOGACTIONS_DELETED) + if (entry->m_Action & CTGitPath::LOGACTIONS_DELETED) { git_index_remove_bypath(index, filePathA); // ignore error } diff --git a/src/TortoiseProc/ProgressCommands/AddProgressCommand.cpp b/src/TortoiseProc/ProgressCommands/AddProgressCommand.cpp index d160f41d2..ff5db9a6a 100644 --- a/src/TortoiseProc/ProgressCommands/AddProgressCommand.cpp +++ b/src/TortoiseProc/ProgressCommands/AddProgressCommand.cpp @@ -53,7 +53,8 @@ bool AddProgressCommand::Run(CGitProgressList* list, CString& sWindowTitle, int& for (m_itemCount = 0; m_itemCount < m_itemCountTotal; ++m_itemCount) { - if (git_index_add_bypath(index, CUnicodeUtils::GetUTF8(m_targetPathList[m_itemCount].GetGitPathString()))) + CStringA filePathA = CUnicodeUtils::GetMulti(m_targetPathList[m_itemCount].GetGitPathString(), CP_UTF8).TrimRight(_T('/')); + if (git_index_add_bypath(index, filePathA)) { list->ReportGitError(); return false; -- 2.11.4.GIT