add support for "git-crypt lock"

This does the reverse of what git-crypt unlock does:
    - unconfigures the git filters
    - forcibly checks out HEAD version

Usage:
    git crypt lock                  locks repo using the "default" key

    git crypt lock -k NAME          locks the repo, using unlocked key named NAME
    git crypt lock --key-name=NAME

    git crypt lock -a               locks the repo, removing ALL unlocked keys
    git crypt lock --all

Result is that you can now decrypt and then revert back to encrypted
form of files and vice versa.

Modified-by: Andrew Ayer <agwa@andrewayer.name>

  * Make argv argument to lock() const.
  * Minor whitespace/style fixes to conform to project conventions.

Signed-off-by: Andrew Ayer <agwa@andrewayer.name>
This commit is contained in:
Michael Schout
2014-09-04 16:23:34 -05:00
committed by Andrew Ayer
parent 316e194f84
commit 3726df181d
3 changed files with 150 additions and 18 deletions

View File

@@ -57,6 +57,7 @@ static void print_usage (std::ostream& out)
//out << " rm-gpg-key KEYID revoke collaborator status from the given GPG key ID" << std::endl;
//out << " ls-gpg-keys list the GPG key IDs of collaborators" << std::endl;
out << " unlock decrypt this repo using the in-repo GPG-encrypted key" << std::endl;
out << " lock check out encrypted versions of files in this repo" << std::endl;
out << std::endl;
out << "Symmetric key commands:" << std::endl;
out << " export-key FILE export this repo's symmetric key to the given file" << std::endl;
@@ -135,6 +136,9 @@ try {
if (std::strcmp(command, "unlock") == 0) {
return unlock(argc, argv);
}
if (std::strcmp(command, "lock") == 0) {
return lock(argc, argv);
}
if (std::strcmp(command, "add-gpg-key") == 0) {
return add_gpg_key(argc, argv);
}