From d0c0e2510b4467245092c95aad0ec4c3d3c2f8fa Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sun, 7 May 2017 12:07:59 +0200 Subject: [PATCH] zfs: FilesystemDiff: support empty left list = no common ancestor --- zfs/diff.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zfs/diff.go b/zfs/diff.go index 90927a7..a10130c 100644 --- a/zfs/diff.go +++ b/zfs/diff.go @@ -138,6 +138,17 @@ func ZFSListFilesystemVersions(fs DatasetPath) (res []FilesystemVersion, err err // names are unique (bas ZFS_PROP_GUID replacement) func MakeFilesystemDiff(left, right []FilesystemVersion) (diff FilesystemDiff) { + if right == nil { + panic("right must not be nil") + } + if left == nil { // treat like no common ancestor + diff = FilesystemDiff{ + IncrementalPath: nil, + Diverged: false, + MRCAPathRight: right, + } + } + // Assert both left and right are sorted by createtxg var leftSorted, rightSorted fsbyCreateTXG leftSorted = left