if (ntohs(1)==1) { ReverseLogHead(&m_stHead); } Crypt((char*)&m_stHead, sizeof(m_stHead), szFilePassword); //memset(szCryptPassword, 0, sizeof(szCryptPassword)); strcpy(szCryptPassword, CRYPTPASSWORD); Crypt(szFilePassword, sizeof(szFilePassword), szCryptPassword); memcpy(m_stHead.stInfo.szPassword, szFilePassword, sizeof(szFilePassword)); fseek(m_fp, 0, SEEK_SET); fwrite(&m_stHead, sizeof(m_stHead), 1, m_fp); fflush(m_fp);
bool AddProgressCommand::Run(CGitProgressList* list, CString& sWindowTitle, int& m_itemCountTotal, int& m_itemCount) { ATLASSERT(!(m_bExecutable && m_bSymlink)); list->SetWindowTitle(IDS_PROGRS_TITLE_ADD, g_Git.CombinePath(m_targetPathList.GetCommonRoot().GetUIPathString()), sWindowTitle); list->SetBackgroundImage(IDI_ADD_BKG); if (m_bExecutable) list->ReportCmd(CString(MAKEINTRESOURCE(IDS_STATUSLIST_CONTEXT_ADD_EXE))); else if (m_bSymlink) list->ReportCmd(CString(MAKEINTRESOURCE(IDS_STATUSLIST_CONTEXT_ADD_LINK))); else list->ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_ADD))); m_itemCountTotal = m_targetPathList.GetCount(); if (g_Git.UsingLibGit2(CGit::GIT_CMD_ADD)) { CAutoRepository repo(g_Git.GetGitRepository()); if (!repo) { list->ReportGitError(); return false; } CAutoIndex index; if (git_repository_index(index.GetPointer(), repo)) { list->ReportGitError(); return false; } if (git_index_read(index, true)) { list->ReportGitError(); return false; } for (m_itemCount = 0; m_itemCount < m_itemCountTotal; ++m_itemCount) { CStringA filePathA = CUnicodeUtils::GetMulti(m_targetPathList[m_itemCount].GetGitPathString(), CP_UTF8).TrimRight(L'/'); if (git_index_add_bypath(index, filePathA)) { list->ReportGitError(); return false; } if (!m_targetPathList[m_itemCount].IsDirectory() && (m_bExecutable || m_bSymlink)) { auto entry = const_cast<git_index_entry*>(git_index_get_bypath(index, filePathA, 0)); if (m_bExecutable) entry->mode = GIT_FILEMODE_BLOB_EXECUTABLE; else if (m_bSymlink) entry->mode = GIT_FILEMODE_LINK; if (git_index_add(index, entry)) { list->ReportGitError(); return false; } } list->AddNotify(new CGitProgressList::WC_File_NotificationData(m_targetPathList[m_itemCount], CGitProgressList::WC_File_NotificationData::git_wc_notify_add)); if (list->IsCancelled() == TRUE) { list->ReportUserCanceled(); return false; } } if (git_index_write(index)) { list->ReportGitError(); return false; } } else { CMassiveGitTask mgt(L"add -f"); if (!mgt.ExecuteWithNotify(&m_targetPathList, list->m_bCancelled, CGitProgressList::WC_File_NotificationData::git_wc_notify_add, list)) return false; if (m_bExecutable) { if (!SetFileMode(GIT_FILEMODE_BLOB_EXECUTABLE)) return false; } else if (m_bSymlink) { if (!SetFileMode(GIT_FILEMODE_LINK)) return false; } } CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList); m_PostCmdCallback = [this](DWORD status, PostCmdList& postCmdList) { if (status) return; if (m_bShowCommitButtonAfterAdd) postCmdList.emplace_back(IDI_COMMIT, IDS_MENUCOMMIT, [] { CString sCmd; sCmd.Format(L"/command:commit /path:\"%s\"", static_cast<LPCTSTR>(g_Git.m_CurrentDir)); CAppUtils::RunTortoiseGitProc(sCmd); }); if (!(m_bExecutable || m_bSymlink)) { postCmdList.emplace_back(IDI_ADD, IDS_STATUSLIST_CONTEXT_ADD_EXE, [this] { SetFileMode(GIT_FILEMODE_BLOB_EXECUTABLE); }); postCmdList.emplace_back(IDI_ADD, IDS_STATUSLIST_CONTEXT_ADD_LINK, [this] { SetFileMode(GIT_FILEMODE_LINK); }); } }; return true; }