CLogDataVector Class
| 48 | |
| 49 | //CLogDataVector Class |
| 50 | int CLogDataVector::ParserFromLog(const CTGitPath* path, DWORD count, DWORD infomask, const CString* range) |
| 51 | { |
| 52 | ATLASSERT(m_pLogCache); |
| 53 | ATLASSERT(!(infomask & CGit::LOG_INFO_FULL_DIFF)); |
| 54 | // only enable --follow on files |
| 55 | if ((!path || path->IsDirectory()) && (infomask & CGit::LOG_INFO_FOLLOW)) |
| 56 | infomask = infomask ^ CGit::LOG_INFO_FOLLOW; |
| 57 | |
| 58 | CString gitrange = L"HEAD"; |
| 59 | if (range != nullptr) |
| 60 | gitrange = *range; |
| 61 | CFilterData filter; |
| 62 | if (count == 0) |
| 63 | filter.m_NumberOfLogsScale = CFilterData::SHOW_NO_LIMIT; |
| 64 | else |
| 65 | { |
| 66 | filter.m_NumberOfLogs = count; |
| 67 | filter.m_NumberOfLogsScale = CFilterData::SHOW_LAST_N_COMMITS; |
| 68 | } |
| 69 | std::vector<std::string> cmd = g_Git.GetLogCmd(gitrange, path, infomask, &filter, m_logOrderBy); |
| 70 | |
| 71 | // if not all branches, all basic refs, all local refs etc. are selected, check whether the selected branch is unborn |
| 72 | if (!(infomask & CGit::LOG_INFO_ALL_BRANCH) && !(infomask & CGit::LOG_INFO_BASIC_REFS) && !(infomask & CGit::LOG_INFO_LOCAL_BRANCHES)) |
| 73 | { |
| 74 | if (const int ret = g_Git.IsUnbornBranch(gitrange); ret < 0) |
| 75 | { |
| 76 | ::MessageBox(nullptr, g_Git.GetGitLastErr(L"Could not check whether the current branch is unborn."), L"TortoiseGit", MB_ICONERROR); |
| 77 | return -1; |
| 78 | } |
| 79 | else if (ret == TRUE) |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | try |
| 84 | { |
| 85 | CAutoLocker lock(g_Git.m_critGitDllSec); |
| 86 | g_Git.ForceReInitDll(); |
| 87 | } |
| 88 | catch (const char* msg) |
| 89 | { |
| 90 | MessageBox(nullptr, L"Could not initialize libgit.\nlibgit reports:\n" + CUnicodeUtils::GetUnicode(msg), L"TortoiseGit", MB_ICONERROR); |
| 91 | return -1; |
| 92 | } |
| 93 | |
| 94 | GIT_LOG handle = nullptr; |
| 95 | try |
| 96 | { |
| 97 | CAutoLocker lock(g_Git.m_critGitDllSec); |
| 98 | auto argvData = CGit::VectorToARGV(cmd); |
| 99 | if (!argvData || git_open_log(&handle, argvData.argc, argvData.argv)) |
| 100 | return -1; |
| 101 | argvData.argv = nullptr; // now we know it'll be freed by git_close_log() |
| 102 | } |
| 103 | catch (const char* msg) |
| 104 | { |
| 105 | CAutoLocker lock(g_Git.m_critGitDllSec); |
| 106 | git_close_log(handle, 0); |
| 107 | MessageBox(nullptr, L"Could not open log.\nlibgit reports:\n" + CUnicodeUtils::GetUnicode(msg), L"TortoiseGit", MB_ICONERROR); |
no test coverage detected