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

Function check_if_file_is_encrypted

commands.cpp:485–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483}
484
485static bool check_if_file_is_encrypted (const std::string& filename)
486{
487 // git ls-files -sz filename
488 std::vector<std::string> command;
489 command.push_back("git");
490 command.push_back("ls-files");
491 command.push_back("-sz");
492 command.push_back("--");
493 command.push_back(filename);
494
495 std::stringstream output;
496 if (!successful_exit(exec_command(command, output))) {
497 throw Error("'git ls-files' failed - is this a Git repository?");
498 }
499
500 if (output.peek() == -1) {
501 return false;
502 }
503
504 std::string mode;
505 std::string object_id;
506 output >> mode >> object_id;
507
508 return check_if_blob_is_encrypted(object_id);
509}
510
511static bool is_git_file_mode (const std::string& mode)
512{

Callers 1

statusFunction · 0.85

Calls 4

successful_exitFunction · 0.85
exec_commandFunction · 0.85
ErrorClass · 0.85

Tested by

no test coverage detected