Skip to content
Snippets Groups Projects
Commit c0d06537 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

gittransport: cleanup

Change-Id: I5f2d557e9527a3ca01834fee072d257d51eae27f
parent c1519ba4
No related branches found
No related tags found
No related merge requests found
...@@ -144,37 +144,37 @@ P2PSubTransportAction(git_smart_subtransport_stream** out, ...@@ -144,37 +144,37 @@ P2PSubTransportAction(git_smart_subtransport_stream** out,
{ {
auto* sub = reinterpret_cast<P2PSubTransport*>(transport); auto* sub = reinterpret_cast<P2PSubTransport*>(transport);
if (!sub || !sub->remote) { if (!sub || !sub->remote) {
JAMI_ERR("Invalid subtransport"); JAMI_ERROR("Invalid subtransport");
return -1; return -1;
} }
auto repo = git_remote_owner(sub->remote); auto repo = git_remote_owner(sub->remote);
if (!repo) { if (!repo) {
JAMI_ERR("No repository linked to the transport"); JAMI_ERROR("No repository linked to the transport");
return -1; return -1;
} }
const auto* workdir = git_repository_workdir(repo); const auto* workdir = git_repository_workdir(repo);
if (!workdir) { if (!workdir) {
JAMI_ERR("No working linked to the repository"); JAMI_ERROR("No working linked to the repository");
return -1; return -1;
} }
std::string_view path = workdir; std::string_view path = workdir;
auto delimConv = path.rfind("/conversations"); auto delimConv = path.rfind("/conversations");
if (delimConv == std::string::npos) { if (delimConv == std::string::npos) {
JAMI_ERR("No conversation id found"); JAMI_ERROR("No conversation id found");
return -1; return -1;
} }
auto delimAccount = path.rfind('/', delimConv - 1); auto delimAccount = path.rfind('/', delimConv - 1);
if (delimAccount == std::string::npos && delimConv - 1 - delimAccount == 16) { if (delimAccount == std::string::npos && delimConv - 1 - delimAccount == 16) {
JAMI_ERR("No account id found"); JAMI_ERROR("No account id found");
return -1; return -1;
} }
auto accountId = path.substr(delimAccount + 1, delimConv - 1 - delimAccount); auto accountId = path.substr(delimAccount + 1, delimConv - 1 - delimAccount);
std::string_view gitUrl = url + std::string("git://").size(); std::string_view gitUrl = url + ("git://"sv).size();
auto delim = gitUrl.find('/'); auto delim = gitUrl.find('/');
if (delim == std::string::npos) { if (delim == std::string::npos) {
JAMI_ERR("Incorrect url %s", std::string(gitUrl).c_str()); JAMI_ERROR("Incorrect url {:s}", gitUrl);
return -1; return -1;
} }
auto deviceId = gitUrl.substr(0, delim); auto deviceId = gitUrl.substr(0, delim);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment