Skip to content

Commit 9cce149

Browse files
committed
address review comment
1 parent deb2b86 commit 9cce149

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/subcommand/init_subcommand.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,22 @@ void init_subcommand::run()
2222
std::filesystem::path target_dir = m_directory;
2323
bool reinit = std::filesystem::exists(target_dir / ".git" / "HEAD");
2424

25-
std::string path;
26-
if (m_branch.empty())
27-
{
28-
auto repo = repository_wrapper::init(m_directory, m_bare);
29-
path = repo.path();
30-
}
31-
else
32-
{
33-
git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
34-
if (m_bare)
25+
repository_wrapper repo = [this]() {
26+
if (m_branch.empty())
3527
{
36-
opts.flags |= GIT_REPOSITORY_INIT_BARE;
28+
return repository_wrapper::init(m_directory, m_bare);
3729
}
38-
opts.initial_head = m_branch.c_str();
30+
else
31+
{
32+
git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
33+
if (m_bare) { opts.flags |= GIT_REPOSITORY_INIT_BARE; }
34+
opts.initial_head = m_branch.c_str();
3935

40-
auto repo = repository_wrapper::init_ext(m_directory, &opts);
41-
path = repo.path();
42-
}
36+
return repository_wrapper::init_ext(m_directory, &opts);
37+
}
38+
}();
39+
40+
std::string path = repo.path();
4341

4442
if (reinit)
4543
{

0 commit comments

Comments
 (0)