MCPcopy Create free account
hub / github.com/AGWA/git-crypt / check_if_blob_is_encrypted

Function check_if_blob_is_encrypted

commands.cpp:464–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

462}
463
464static bool check_if_blob_is_encrypted (const std::string& object_id)
465{
466 // git cat-file blob object_id
467
468 std::vector<std::string> command;
469 command.push_back("git");
470 command.push_back("cat-file");
471 command.push_back("blob");
472 command.push_back(object_id);
473
474 // TODO: do this more efficiently - don't read entire command output into buffer, only read what we need
475 std::stringstream output;
476 if (!successful_exit(exec_command(command, output))) {
477 throw Error("'git cat-file' failed - is this a Git repository?");
478 }
479
480 char header[10];
481 output.read(header, sizeof(header));
482 return output.gcount() == sizeof(header) && std::memcmp(header, "\0GITCRYPT\0", 10) == 0;
483}
484
485static bool check_if_file_is_encrypted (const std::string& filename)
486{

Callers 2

statusFunction · 0.85

Calls 3

successful_exitFunction · 0.85
exec_commandFunction · 0.85
ErrorClass · 0.85

Tested by

no test coverage detected