minor fixes
This commit is contained in:
parent
4affce9f0f
commit
1edc5ec7cd
|
|
@ -34,5 +34,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT basic-vcs)
|
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT basic-vcs)
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
target_link_libraries(basic-vcs PRIVATE curl)
|
||||||
|
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -122,8 +122,10 @@ int commitTree(int argc, const char** argv)
|
||||||
SHA1 checksum;
|
SHA1 checksum;
|
||||||
checksum.update(commitObject);
|
checksum.update(commitObject);
|
||||||
const std::string hash = checksum.final();
|
const std::string hash = checksum.final();
|
||||||
const std::filesystem::path hashDir{ std::filesystem::current_path() / ".git" / "objects" / hash.substr(0,2) };
|
std::cout << hash << "\n";
|
||||||
const std::filesystem::path objectFullPath{ hashDir / hash.substr(2) };
|
|
||||||
|
const std::filesystem::path hashDir{ std::filesystem::current_path() / ".git" / "objects" / hash.substr(0,2) };
|
||||||
|
const std::filesystem::path objectFullPath{ hashDir / hash.substr(2) };
|
||||||
|
|
||||||
if (!std::filesystem::exists(hashDir))
|
if (!std::filesystem::exists(hashDir))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -85,13 +85,13 @@ std::string hashDir(const std::string& path)
|
||||||
std::string fileContent {std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()};
|
std::string fileContent {std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()};
|
||||||
|
|
||||||
SHA1 checksum;
|
SHA1 checksum;
|
||||||
std::string blob = "blob " + std::to_string(fileContent.size());
|
std::string blob = "blob " + std::to_string(fileContent.size());
|
||||||
blob.append("\0");
|
blob.append("\0");
|
||||||
blob.append(fileContent);
|
blob.append(fileContent);
|
||||||
|
|
||||||
checksum.update(blob);
|
checksum.update(blob);
|
||||||
|
|
||||||
nodes.emplace_back(object.path().filename().string(), 100644, checksum.final());
|
nodes.emplace_back(object.path().filename().string(), 100644, checksum.final());
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue