Skip to content

Commit 95aa003

Browse files
committed
Used strarray_owned_wrapper in tag_list_match method
1 parent 4c954bb commit 95aa003

6 files changed

Lines changed: 13 additions & 18 deletions

File tree

src/subcommand/push_subcommand.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <git2/remote.h>
88

99
#include "../utils/ansi_code.hpp"
10-
//#include "../utils/common.hpp"
1110
#include "../utils/credentials.hpp"
1211
#include "../utils/progress.hpp"
1312
#include "../wasm/scope.hpp"

src/subcommand/tag_subcommand.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ void tag_subcommand::list_tags(repository_wrapper& repo)
136136
std::string pattern = m_tag_name.empty() ? "*" : m_tag_name;
137137
auto tag_names = repo.tag_list_match(pattern);
138138

139-
for (const auto& tag_name : tag_names)
139+
for (size_t i = 0u; i < tag_names.size(); ++i)
140140
{
141-
each_tag(repo, tag_name, m_num_lines);
141+
each_tag(repo, tag_names[i], m_num_lines);
142142
}
143143
}
144144

src/wrapper/repository_wrapper.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
#include "../utils/git_exception.hpp"
88
#include "../wrapper/commit_wrapper.hpp"
9+
#include "../wrapper/config_wrapper.hpp"
10+
#include "../wrapper/diff_wrapper.hpp"
911
#include "../wrapper/index_wrapper.hpp"
1012
#include "../wrapper/object_wrapper.hpp"
1113
#include "../wrapper/remote_wrapper.hpp"
12-
#include "config_wrapper.hpp"
13-
#include "diff_wrapper.hpp"
1414

1515
repository_wrapper::~repository_wrapper()
1616
{
@@ -651,13 +651,10 @@ repository_wrapper::diff_index_to_workdir(std::optional<index_wrapper> index, gi
651651

652652
// Tags
653653

654-
std::vector<std::string> repository_wrapper::tag_list_match(std::string pattern)
654+
strarray_owned_wrapper repository_wrapper::tag_list_match(std::string pattern)
655655
{
656-
git_strarray tag_names;
657-
throw_if_error(git_tag_list_match(&tag_names, pattern.c_str(), *this));
658-
659-
std::vector<std::string> result(tag_names.strings, tag_names.strings + tag_names.count);
660-
661-
git_strarray_dispose(&tag_names);
662-
return result;
656+
strarray_owned_wrapper tag_names;
657+
throw_if_error(git_tag_list_match(tag_names, pattern.c_str(), *this));
658+
return tag_names;
663659
}
660+

src/wrapper/repository_wrapper.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "../wrapper/remote_wrapper.hpp"
2020
#include "../wrapper/revwalk_wrapper.hpp"
2121
#include "../wrapper/signature_wrapper.hpp"
22+
#include "../wrapper/strarray_wrapper.hpp"
2223
#include "../wrapper/tree_wrapper.hpp"
2324
#include "../wrapper/wrapper_base.hpp"
2425

@@ -134,8 +135,7 @@ class repository_wrapper : public wrapper_base<git_repository>
134135
diff_wrapper diff_index_to_workdir(std::optional<index_wrapper> index, git_diff_options* diffopts);
135136

136137
// Tags
137-
// strarray_view_wrapper tag_list_match(std::string pattern);
138-
std::vector<std::string> tag_list_match(std::string pattern);
138+
strarray_owned_wrapper tag_list_match(std::string pattern);
139139

140140
private:
141141

src/wrapper/strarray_wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ size_t strarray_owned_wrapper::size() const
3838
return m_array.count;
3939
}
4040

41-
std::string_view strarray_owned_wrapper::operator[](size_t i) const
41+
std::string strarray_owned_wrapper::operator[](size_t i) const
4242
{
4343
return { m_array.strings[i] };
4444
}

src/wrapper/strarray_wrapper.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include <string>
4-
#include <string_view>
54
#include <vector>
65

76
#include <git2.h>
@@ -27,7 +26,7 @@ class strarray_owned_wrapper
2726

2827
size_t size() const;
2928

30-
std::string_view operator[](size_t i) const;
29+
std::string operator[](size_t i) const;
3130

3231
private:
3332

0 commit comments

Comments
 (0)