mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-19 16:16:48 +00:00
Cleanup branches and add more unit tests
This commit is contained in:
committed by
trapexit
parent
a30a4df9c0
commit
7f52623536
+1
-9
@@ -17,11 +17,10 @@
|
||||
*/
|
||||
|
||||
#include "branch.hpp"
|
||||
#include "ef.hpp"
|
||||
#include "errno.hpp"
|
||||
#include "num.hpp"
|
||||
|
||||
Branch::Branch()
|
||||
: mode(Branch::Mode::RW)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,12 +36,6 @@ Branch::Branch(const u64 &default_minfreespace_)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
Branch::from_string(const std::string_view str_)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
std::string
|
||||
Branch::to_string(void) const
|
||||
{
|
||||
@@ -64,7 +57,6 @@ Branch::to_string(void) const
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(std::holds_alternative<u64>(_minfreespace))
|
||||
{
|
||||
rv += ',';
|
||||
|
||||
+2
-5
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "base_types.h"
|
||||
#include "strvec.hpp"
|
||||
#include "tofrom_string.hpp"
|
||||
#include "fs_path.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
@@ -31,12 +30,11 @@
|
||||
#include <variant>
|
||||
|
||||
|
||||
class Branch final : public ToFromString
|
||||
class Branch final
|
||||
{
|
||||
public:
|
||||
enum class Mode
|
||||
{
|
||||
INVALID,
|
||||
RO,
|
||||
RW,
|
||||
NC
|
||||
@@ -61,8 +59,7 @@ public:
|
||||
bool ro_or_nc(void) const;
|
||||
|
||||
public:
|
||||
int from_string(const std::string_view str) final;
|
||||
std::string to_string(void) const final;
|
||||
std::string to_string(void) const;
|
||||
|
||||
public:
|
||||
u64 minfreespace() const;
|
||||
|
||||
+10
-1
@@ -82,7 +82,10 @@ namespace l
|
||||
|
||||
offset = s_.find_first_not_of("+<>-=");
|
||||
if(offset == std::string::npos)
|
||||
return;
|
||||
{
|
||||
*instr_ = s_.substr(0, std::min(s_.size(), (size_t)2));
|
||||
return;
|
||||
}
|
||||
|
||||
if(offset > 1)
|
||||
offset = 2;
|
||||
@@ -293,6 +296,9 @@ namespace l
|
||||
int
|
||||
erase_begin(Branches::Impl *branches_)
|
||||
{
|
||||
if(branches_->empty())
|
||||
return -ENOENT;
|
||||
|
||||
branches_->erase(branches_->begin());
|
||||
|
||||
return 0;
|
||||
@@ -302,6 +308,9 @@ namespace l
|
||||
int
|
||||
erase_end(Branches::Impl *branches_)
|
||||
{
|
||||
if(branches_->empty())
|
||||
return -ENOENT;
|
||||
|
||||
branches_->pop_back();
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user