You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'git-crypt status' tells you which files are and aren't encrypted and
detects other problems with your git-crypt setup.
'git-crypt status -f' can be used to re-stage files that were incorrectly
staged unencrypted.
The UI needs work, and it needs to also output the overall repository
status (such as, is git-crypt even configured yet?), but this is a
good start.
if (show_encrypted_only || show_unencrypted_only) {
948
+
std::clog << "Error: -e and -u options cannot be used with -r" << std::endl;
949
+
return2;
950
+
}
951
+
if (fix_problems) {
952
+
std::clog << "Error: -f option cannot be used with -r" << std::endl;
953
+
return2;
954
+
}
955
+
if (argc - argi != 0) {
956
+
std::clog << "Error: filenames cannot be specified when -r is used" << std::endl;
957
+
return2;
958
+
}
959
+
}
960
+
961
+
if (show_encrypted_only && show_unencrypted_only) {
962
+
std::clog << "Error: -e and -u options are mutually exclusive" << std::endl;
963
+
return2;
964
+
}
965
+
966
+
if (fix_problems && (show_encrypted_only || show_unencrypted_only)) {
967
+
std::clog << "Error: -e and -u options cannot be used with -f" << std::endl;
968
+
return2;
969
+
}
970
+
971
+
if (machine_output) {
972
+
// TODO: implement machine-parseable output
973
+
std::clog << "Sorry, machine-parseable output is not yet implemented" << std::endl;
974
+
return2;
975
+
}
976
+
977
+
if (argc - argi == 0) {
978
+
// TODO: check repo status:
979
+
// is it set up for git-crypt?
980
+
// which keys are unlocked?
981
+
// --> check for filter config (see configure_git_filters()) and corresponding internal key
982
+
983
+
if (repo_status_only) {
984
+
return0;
985
+
}
986
+
}
987
+
988
+
// git ls-files -cotsz --exclude-standard ...
989
+
std::vector<std::string> command;
990
+
command.push_back("git");
991
+
command.push_back("ls-files");
992
+
command.push_back("-cotsz");
993
+
command.push_back("--exclude-standard");
994
+
command.push_back("--");
995
+
if (argc - argi == 0) {
996
+
const std::string path_to_top(get_path_to_top());
997
+
if (!path_to_top.empty()) {
998
+
command.push_back(path_to_top);
999
+
}
1000
+
} else {
1001
+
for (int i = argi; i < argc; ++i) {
1002
+
command.push_back(argv[i]);
1003
+
}
1004
+
}
1005
+
1006
+
std::stringstream output;
1007
+
if (!successful_exit(exec_command(command, output))) {
1008
+
throwError("'git ls-files' failed - is this a Git repository?");
1009
+
}
1010
+
1011
+
// Output looks like (w/o newlines):
1012
+
// ? .gitignore\0
1013
+
// H 100644 06ec22e5ed0de9280731ef000a10f9c3fbc26338 0 afile\0
1014
+
1015
+
std::vector<std::string> files;
1016
+
bool attribute_errors = false;
1017
+
bool unencrypted_blob_errors = false;
1018
+
unsignedint nbr_of_fixed_blobs = 0;
1019
+
unsignedint nbr_of_fix_errors = 0;
1020
+
1021
+
while (output.peek() != -1) {
1022
+
std::string tag;
1023
+
std::string object_id;
1024
+
std::string filename;
1025
+
output >> tag;
1026
+
if (tag != "?") {
1027
+
std::string mode;
1028
+
std::string stage;
1029
+
output >> mode >> object_id >> stage;
1030
+
}
1031
+
output >> std::ws;
1032
+
std::getline(output, filename, '\0');
1033
+
1034
+
// TODO: get file attributes en masse for efficiency... unfortunately this requires machine-parseable output from git check-attr to be workable, and this is only supported in Git 1.8.5 and above (released 27 Nov 2013)
std::clog << "Error: " << filename << ": cannot stage encrypted version because not present in working tree - please 'git rm' or 'git checkout' it" << std::endl;
1044
+
++nbr_of_fix_errors;
1045
+
} else {
1046
+
touch_file(filename);
1047
+
std::vector<std::string> git_add_command;
1048
+
git_add_command.push_back("git");
1049
+
git_add_command.push_back("add");
1050
+
git_add_command.push_back("--");
1051
+
git_add_command.push_back(filename);
1052
+
if (!successful_exit(exec_command(git_add_command))) {
0 commit comments