]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- fixed creating root config (root prefix handling) 628/head
authorArvin Schnell <aschnell@suse.de>
Fri, 19 Mar 2021 09:53:11 +0000 (10:53 +0100)
committerArvin Schnell <aschnell@suse.de>
Fri, 19 Mar 2021 09:53:11 +0000 (10:53 +0100)
LIBVERSION
VERSION
package/snapper.changes
snapper/AppUtil.cc
testsuite/Makefile.am
testsuite/root-prefix.cc [new file with mode: 0644]

index 91ff57278e37ef9cecfeaea47f0d77966799af28..26d99a283f21aa125ccd146e50e76a9b643f54f1 100644 (file)
@@ -1 +1 @@
-5.2.0
+5.2.1
diff --git a/VERSION b/VERSION
index 7d87d9947c2de74ef8044547b2181e65af943b6e..ac7dffa0699e065ffdd5b178b7d5886a43ec8e35 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.8.15
+0.8.16
index 125779577e405aedd2e49e48ae73e5778c7ce2d3..701b9eeac275282c38650ed66363e8c0c7adb593 100644 (file)
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Fri Mar 19 10:30:06 CET 2021 - aschnell@suse.com
+
+- fixed creating root config (root prefix handling)
+  (gh#openSUSE/snapper#627)
+
 -------------------------------------------------------------------
 Wed Mar 10 09:53:11 CET 2021 - aschnell@suse.com
 
index b78ff3027388aedee3e3afefc70a4d554788074f..4fe6d472015517cf8f8f6e2103fcae45610d5028 100644 (file)
@@ -147,7 +147,9 @@ namespace snapper
     string
     prepend_root_prefix(const string& root_prefix, const string& path)
     {
-       if (root_prefix == "/")
+       // TODO use std::filesystem (C++17)
+
+       if (root_prefix == "/" || root_prefix.empty())
            return path;
        else if (path == "/")
            return root_prefix;
index cfd1002d59efad575857e8397a1254f26096bb8e..beb8151d824a0017371f1ff05ad4291779a9dbdb 100644 (file)
@@ -9,7 +9,7 @@ LDADD = ../snapper/libsnapper.la ../dbus/libdbus.la -lboost_unit_test_framework
 check_PROGRAMS = sysconfig-get1.test dirname1.test basename1.test              \
        equal-date.test dbus-escape.test cmp-lt.test humanstring.test           \
        table.test table-formatter.test csv-formatter.test json-formatter.test  \
-       getopts.test scan-datetime.test
+       getopts.test scan-datetime.test root-prefix.test
 
 if ENABLE_BTRFS_QUOTA
 check_PROGRAMS += qgroup1.test
diff --git a/testsuite/root-prefix.cc b/testsuite/root-prefix.cc
new file mode 100644 (file)
index 0000000..e624ac9
--- /dev/null
@@ -0,0 +1,22 @@
+
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE root_prefix
+
+#include <boost/test/unit_test.hpp>
+
+#include <snapper/AppUtil.h>
+
+using namespace snapper;
+
+
+BOOST_AUTO_TEST_CASE(root_prefix)
+{
+    BOOST_CHECK_EQUAL(prepend_root_prefix("", "/"), "/");
+    BOOST_CHECK_EQUAL(prepend_root_prefix("", "/home"), "/home");
+
+    BOOST_CHECK_EQUAL(prepend_root_prefix("/", "/"), "/");
+    BOOST_CHECK_EQUAL(prepend_root_prefix("/", "/home"), "/home");
+
+    BOOST_CHECK_EQUAL(prepend_root_prefix("/mnt", "/"), "/mnt");
+    BOOST_CHECK_EQUAL(prepend_root_prefix("/mnt", "/home"), "/mnt/home");
+}