From ad98fbf7dd847e4a5888475f1ef6456ffb491dc3 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 19 May 2024 20:37:19 +0200 Subject: [PATCH] restic: add IDSet.Clone() method --- internal/restic/idset.go | 6 ++++++ internal/restic/idset_test.go | 3 +++ 2 files changed, 9 insertions(+) diff --git a/internal/restic/idset.go b/internal/restic/idset.go index 1b12a6398..9e6e3c6fd 100644 --- a/internal/restic/idset.go +++ b/internal/restic/idset.go @@ -105,3 +105,9 @@ func (s IDSet) String() string { str := s.List().String() return "{" + str[1:len(str)-1] + "}" } + +func (s IDSet) Clone() IDSet { + c := NewIDSet() + c.Merge(s) + return c +} diff --git a/internal/restic/idset_test.go b/internal/restic/idset_test.go index 734b31237..14c88b314 100644 --- a/internal/restic/idset_test.go +++ b/internal/restic/idset_test.go @@ -35,4 +35,7 @@ func TestIDSet(t *testing.T) { } rtest.Equals(t, "{1285b303 7bb086db f658198b}", set.String()) + + copied := set.Clone() + rtest.Equals(t, "{1285b303 7bb086db f658198b}", copied.String()) }