Skip to content

Commit deb2b86

Browse files
committed
address review comments
1 parent f6924a9 commit deb2b86

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

src/subcommand/init_subcommand.cpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,23 @@ 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 git_path;
25+
std::string path;
2626
if (m_branch.empty())
2727
{
2828
auto repo = repository_wrapper::init(m_directory, m_bare);
29-
git_path = repo.git_path();
29+
path = repo.path();
3030
}
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);
38-
git_path = repo.git_path();
39-
}
40-
41-
std::string path;
42-
if (m_bare)
43-
{
44-
size_t pos = git_path.find(".git/");
45-
path = git_path.substr(0, pos);
46-
}
47-
else
48-
{
49-
path = git_path;
41+
path = repo.path();
5042
}
5143

5244
if (reinit)

src/wrapper/repository_wrapper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ repository_wrapper repository_wrapper::clone(std::string_view url, std::string_v
4545
return rw;
4646
}
4747

48-
std::string repository_wrapper::git_path() const
48+
std::string repository_wrapper::path() const
4949
{
5050
return git_repository_path(*this);
5151
}
@@ -350,8 +350,8 @@ size_t repository_wrapper::shallow_depth_from_head() const
350350
return 0u;
351351
}
352352

353-
std::string git_path = this->git_path();
354-
std::string shallow_path = git_path + "shallow";
353+
std::string path = this->path();
354+
std::string shallow_path = path + "shallow";
355355

356356
std::vector<git_oid> boundaries_list;
357357
std::ifstream f(shallow_path);

src/wrapper/repository_wrapper.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class repository_wrapper : public wrapper_base<git_repository>
4444
static repository_wrapper open(std::string_view directory);
4545
static repository_wrapper clone(std::string_view url, std::string_view path, const git_clone_options& opts);
4646

47-
std::string git_path() const;
47+
std::string path() const;
4848
git_repository_state_t state() const;
4949
void state_cleanup();
5050

0 commit comments

Comments
 (0)