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

Function status

commands.cpp:1514–1707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1512 out << std::endl;
1513}
1514int status (int argc, const char** argv)
1515{
1516 // Usage:
1517 // git-crypt status -r [-z] Show repo status
1518 // git-crypt status [-e | -u] [-z] [FILE ...] Show encrypted status of files
1519 // git-crypt status -f Fix unencrypted blobs
1520
1521 bool repo_status_only = false; // -r show repo status only
1522 bool show_encrypted_only = false; // -e show encrypted files only
1523 bool show_unencrypted_only = false; // -u show unencrypted files only
1524 bool fix_problems = false; // -f fix problems
1525 bool machine_output = false; // -z machine-parseable output
1526
1527 Options_list options;
1528 options.push_back(Option_def("-r", &repo_status_only));
1529 options.push_back(Option_def("-e", &show_encrypted_only));
1530 options.push_back(Option_def("-u", &show_unencrypted_only));
1531 options.push_back(Option_def("-f", &fix_problems));
1532 options.push_back(Option_def("--fix", &fix_problems));
1533 options.push_back(Option_def("-z", &machine_output));
1534
1535 int argi = parse_options(options, argc, argv);
1536
1537 if (repo_status_only) {
1538 if (show_encrypted_only || show_unencrypted_only) {
1539 std::clog << "Error: -e and -u options cannot be used with -r" << std::endl;
1540 return 2;
1541 }
1542 if (fix_problems) {
1543 std::clog << "Error: -f option cannot be used with -r" << std::endl;
1544 return 2;
1545 }
1546 if (argc - argi != 0) {
1547 std::clog << "Error: filenames cannot be specified when -r is used" << std::endl;
1548 return 2;
1549 }
1550 }
1551
1552 if (show_encrypted_only && show_unencrypted_only) {
1553 std::clog << "Error: -e and -u options are mutually exclusive" << std::endl;
1554 return 2;
1555 }
1556
1557 if (fix_problems && (show_encrypted_only || show_unencrypted_only)) {
1558 std::clog << "Error: -e and -u options cannot be used with -f" << std::endl;
1559 return 2;
1560 }
1561
1562 if (machine_output) {
1563 // TODO: implement machine-parseable output
1564 std::clog << "Sorry, machine-parseable output is not yet implemented" << std::endl;
1565 return 2;
1566 }
1567
1568 if (argc - argi == 0) {
1569 // TODO: check repo status:
1570 // is it set up for git-crypt?
1571 // which keys are unlocked?

Callers 1

mainFunction · 0.85

Calls 11

Option_defClass · 0.85
parse_optionsFunction · 0.85
get_path_to_topFunction · 0.85
successful_exitFunction · 0.85
exec_commandFunction · 0.85
ErrorClass · 0.85
is_git_file_modeFunction · 0.85
get_file_attributesFunction · 0.85
touch_fileFunction · 0.70

Tested by

no test coverage detected