Skip to content

Commit

Permalink
When adding GPG collaborator, include full fingerprint in commit message
Browse files Browse the repository at this point in the history
Short key IDs are bad (https://evil32.com/)

Closes: AGWA#253
  • Loading branch information
AGWA committed Jun 7, 2022
1 parent a1e6311 commit 08dbdcf
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
3 changes: 2 additions & 1 deletion commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,8 @@ int add_gpg_user (int argc, const char** argv)
std::ostringstream commit_message_builder;
commit_message_builder << "Add " << collab_keys.size() << " git-crypt collaborator" << (collab_keys.size() != 1 ? "s" : "") << "\n\nNew collaborators:\n\n";
for (std::vector<std::pair<std::string, bool> >::const_iterator collab(collab_keys.begin()); collab != collab_keys.end(); ++collab) {
commit_message_builder << '\t' << gpg_shorten_fingerprint(collab->first) << ' ' << gpg_get_uid(collab->first) << '\n';
commit_message_builder << " " << collab->first << '\n';
commit_message_builder << " " << gpg_get_uid(collab->first) << '\n';
}

// git commit -m MESSAGE NEW_FILE ...
Expand Down
6 changes: 0 additions & 6 deletions gpg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ static std::string gpg_nth_column (const std::string& line, unsigned int col)
line.substr(pos);
}

// given a key fingerprint, return the last 8 nibbles
std::string gpg_shorten_fingerprint (const std::string& fingerprint)
{
return fingerprint.size() == 40 ? fingerprint.substr(32) : fingerprint;
}

// given a key fingerprint, return the key's UID (e.g. "John Smith <jsmith@example.com>")
std::string gpg_get_uid (const std::string& fingerprint)
{
Expand Down
1 change: 0 additions & 1 deletion gpg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ struct Gpg_error {
explicit Gpg_error (std::string m) : message(m) { }
};

std::string gpg_shorten_fingerprint (const std::string& fingerprint);
std::string gpg_get_uid (const std::string& fingerprint);
std::vector<std::string> gpg_lookup_key (const std::string& query);
std::vector<std::string> gpg_list_secret_keys ();
Expand Down

0 comments on commit 08dbdcf

Please sign in to comment.