We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f6924a9 commit bbfda5bCopy full SHA for bbfda5b
1 file changed
src/subcommand/init_subcommand.cpp
@@ -31,7 +31,10 @@ void init_subcommand::run()
31
else
32
{
33
git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
34
- if (m_bare) {opts.flags |= GIT_REPOSITORY_INIT_BARE;}
+ if (m_bare)
35
+ {
36
+ opts.flags |= GIT_REPOSITORY_INIT_BARE;
37
+ }
38
opts.initial_head = m_branch.c_str();
39
40
auto repo = repository_wrapper::init_ext(m_directory, &opts);
@@ -42,7 +45,14 @@ void init_subcommand::run()
42
45
if (m_bare)
43
46
44
47
size_t pos = git_path.find(".git/");
- path = git_path.substr(0, pos);
48
+ if (pos != std::string::npos)
49
50
+ path = git_path.substr(0, pos);
51
52
+ else
53
54
+ throw git_exception("'.git/' not found in the path of the repository.", git2cpp_error_code::FILESYSTEM_ERROR);
55
56
}
57
58
0 commit comments