| 462 | } |
| 463 | |
| 464 | static 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 | |
| 485 | static bool check_if_file_is_encrypted (const std::string& filename) |
| 486 | { |
no test coverage detected