Browse Source

return ENOTSUP when branches empty after update

pull/1074/head
Matthieu Berthomé 2 years ago
parent
commit
f5937adbcb
  1. 11
      src/branches.cpp

11
src/branches.cpp

@ -205,6 +205,9 @@ namespace l
Branches::Impl tmp_branches(branches_->minfreespace()); Branches::Impl tmp_branches(branches_->minfreespace());
str::split(str_,':',&paths); str::split(str_,':',&paths);
if (paths.empty())
return -ENOTSUP;
for(auto &path : paths) for(auto &path : paths)
{ {
rv = l::parse(path,&tmp_branches); rv = l::parse(path,&tmp_branches);
@ -269,6 +272,9 @@ namespace l
int int
erase_begin(Branches::Impl *branches_) erase_begin(Branches::Impl *branches_)
{ {
if (branches_->size() <= 1)
return -ENOTSUP;
branches_->erase(branches_->begin()); branches_->erase(branches_->begin());
return 0; return 0;
@ -278,6 +284,9 @@ namespace l
int int
erase_end(Branches::Impl *branches_) erase_end(Branches::Impl *branches_)
{ {
if (branches_->size() <= 1)
return -ENOTSUP;
branches_->pop_back(); branches_->pop_back();
return 0; return 0;
@ -299,6 +308,8 @@ namespace l
{ {
match = ::fnmatch(pi->c_str(),i->path.c_str(),0); match = ::fnmatch(pi->c_str(),i->path.c_str(),0);
} }
if (match == 0 && branches_->size() == 1)
return -ENOTSUP;
i = ((match == 0) ? branches_->erase(i) : (i+1)); i = ((match == 0) ? branches_->erase(i) : (i+1));
} }

Loading…
Cancel
Save