File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,10 @@ void init_subcommand::run()
3131 else
3232 {
3333 git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
34- if (m_bare) {opts.flags |= GIT_REPOSITORY_INIT_BARE;}
34+ if (m_bare)
35+ {
36+ opts.flags |= GIT_REPOSITORY_INIT_BARE;
37+ }
3538 opts.initial_head = m_branch.c_str ();
3639
3740 auto repo = repository_wrapper::init_ext (m_directory, &opts);
@@ -42,7 +45,14 @@ void init_subcommand::run()
4245 if (m_bare)
4346 {
4447 size_t pos = git_path.find (" .git/" );
45- 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+ }
4656 }
4757 else
4858 {
You can’t perform that action at this time.
0 commit comments