From 38b2e9b42caa1fc35d317764c99c3ebe72db662c Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 10 Dec 2022 12:40:41 +0100 Subject: [PATCH] rewrite: Always set the Original field in a rewritten snapshot The Original field is meant to remember the original snapshot id if e.g. changing its tags. It was only set by the `rewrite` command if it was not set previously. However, a rewritten snapshot is potentially rather different from the original snapshot. Thus just always set the Original field. This also makes it easier to later on detect and potentially remove the original snapshots. --- changelog/unreleased/issue-14 | 1 + cmd/restic/cmd_rewrite.go | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/changelog/unreleased/issue-14 b/changelog/unreleased/issue-14 index 93f83686d..e97541f4d 100644 --- a/changelog/unreleased/issue-14 +++ b/changelog/unreleased/issue-14 @@ -5,3 +5,4 @@ unwanted files. https://github.com/restic/restic/issues/14 https://github.com/restic/restic/pull/2731 +https://github.com/restic/restic/pull/4079 diff --git a/cmd/restic/cmd_rewrite.go b/cmd/restic/cmd_rewrite.go index 2a750b969..cfe56db87 100644 --- a/cmd/restic/cmd_rewrite.go +++ b/cmd/restic/cmd_rewrite.go @@ -123,10 +123,8 @@ func rewriteSnapshot(ctx context.Context, repo *repository.Repository, sn *resti return true, nil } - // Retain the original snapshot id over all tag changes. - if sn.Original == nil { - sn.Original = sn.ID() - } + // Always set the original snapshot id as this essentially a new snapshot. + sn.Original = sn.ID() *sn.Tree = filteredTree if !opts.Forget {