| 446 | } |
| 447 | |
| 448 | int CRepositoryBrowser::ReadTree(CShadowFilesTree* treeroot, const CString& root, bool recursive) |
| 449 | { |
| 450 | CWaitCursor wait; |
| 451 | CAutoRepository repository(g_Git.GetGitRepository()); |
| 452 | if (!repository) |
| 453 | { |
| 454 | MessageBox(CGit::GetLibGit2LastErr(L"Could not open repository."), L"TortoiseGit", MB_ICONERROR); |
| 455 | return -1; |
| 456 | } |
| 457 | |
| 458 | if (m_sRevision == L"HEAD") |
| 459 | { |
| 460 | int ret = git_repository_head_unborn(repository); |
| 461 | if (ret == 1) // is orphan |
| 462 | return ret; |
| 463 | else if (ret != 0) |
| 464 | { |
| 465 | MessageBox(g_Git.GetLibGit2LastErr(L"Could not check HEAD."), L"TortoiseGit", MB_ICONERROR); |
| 466 | return ret; |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | CGitHash hash; |
| 471 | if (CGit::GetHash(repository, hash, m_sRevision + L"^{}")) // add ^{} in order to dereference signed tags |
| 472 | { |
| 473 | MessageBox(CGit::GetLibGit2LastErr(L"Could not get hash of \"" + m_sRevision + L"^{}\"."), L"TortoiseGit", MB_ICONERROR); |
| 474 | return -1; |
| 475 | } |
| 476 | |
| 477 | CAutoObject object; |
| 478 | if (git_object_lookup(object.GetPointer(), repository, hash, GIT_OBJECT_ANY) < 0) |
| 479 | { |
| 480 | MessageBox(CGit::GetLibGit2LastErr(L"Could not lookup object."), L"TortoiseGit", MB_ICONERROR); |
| 481 | return -1; |
| 482 | } |
| 483 | |
| 484 | CAutoTree tree; |
| 485 | if (git_object_type(object) == GIT_OBJECT_COMMIT) |
| 486 | { |
| 487 | CAutoCommit commit{ std::move(object) }; |
| 488 | if (git_commit_tree(tree.GetPointer(), commit)) |
| 489 | { |
| 490 | MessageBox(CGit::GetLibGit2LastErr(L"Could not get tree of commit."), L"TortoiseGit", MB_ICONERROR); |
| 491 | return -1; |
| 492 | } |
| 493 | } |
| 494 | else if (git_object_type(object) == GIT_OBJECT_TREE) |
| 495 | tree.ConvertFrom(std::move(object)); |
| 496 | else |
| 497 | { |
| 498 | MessageBox(CGit::GetLibGit2LastErr(L"Found unknown object type."), L"TortoiseGit", MB_ICONERROR); |
| 499 | return -1; |
| 500 | } |
| 501 | |
| 502 | if (!root.IsEmpty()) |
| 503 | { |
| 504 | CAutoTreeEntry treeEntry; |
| 505 | if (git_tree_entry_bypath(treeEntry.GetPointer(), tree, CUnicodeUtils::GetUTF8(root))) |
nothing calls this directly
no test coverage detected