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

Function get_repo_state_path

commands.cpp:301–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299}
300
301static std::string get_repo_state_path ()
302{
303 // git rev-parse --show-toplevel
304 std::vector<std::string> command;
305 command.push_back("git");
306 command.push_back("rev-parse");
307 command.push_back("--show-toplevel");
308
309 std::stringstream output;
310
311 if (!successful_exit(exec_command(command, output))) {
312 throw Error("'git rev-parse --show-toplevel' failed - is this a Git repository?");
313 }
314
315 std::string path;
316 std::getline(output, path);
317
318 if (path.empty()) {
319 // could happen for a bare repo
320 throw Error("Could not determine Git working tree - is this a non-bare repo?");
321 }
322
323 // Check if the repo state dir has been explicitly configured. If so, use that in path construction.
324 if (git_has_config("git-crypt.repoStateDir")) {
325 std::string repoStateDir = get_git_config("git-crypt.repoStateDir");
326
327 // The repoStateDir value must always be relative to git work tree to ensure the repoStateDir can be committed
328 // along with the remainder of the repository.
329 path += '/' + repoStateDir;
330 } else {
331 // There is no explicitly configured repo state dir configured, so use the default.
332 path += "/.git-crypt";
333 }
334
335 return path;
336}
337
338static std::string get_repo_keys_path (const std::string& repo_state_path)
339{

Callers 2

get_repo_keys_pathFunction · 0.85
add_gpg_userFunction · 0.85

Calls 5

successful_exitFunction · 0.85
exec_commandFunction · 0.85
ErrorClass · 0.85
git_has_configFunction · 0.85
get_git_configFunction · 0.85

Tested by

no test coverage detected