From efb4315a1e584d87c6ceed05daf7aeae581aca5a Mon Sep 17 00:00:00 2001 From: Pauline Middelink Date: Thu, 2 Mar 2017 22:41:11 +0100 Subject: [PATCH 1/3] Display absolute paths when displaying the output of ls and find. --- src/cmds/restic/cmd_find.go | 2 +- src/cmds/restic/cmd_ls.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmds/restic/cmd_find.go b/src/cmds/restic/cmd_find.go index 0eef529a6..ab628c414 100644 --- a/src/cmds/restic/cmd_find.go +++ b/src/cmds/restic/cmd_find.go @@ -129,7 +129,7 @@ func findInSnapshot(repo *repository.Repository, pat findPattern, id restic.ID) return err } - results, err := findInTree(repo, pat, *sn.Tree, "") + results, err := findInTree(repo, pat, *sn.Tree, string(filepath.Separator)) if err != nil { return err } diff --git a/src/cmds/restic/cmd_ls.go b/src/cmds/restic/cmd_ls.go index 2dfa5cc52..c6c05bec1 100644 --- a/src/cmds/restic/cmd_ls.go +++ b/src/cmds/restic/cmd_ls.go @@ -121,5 +121,5 @@ func runLs(gopts GlobalOptions, args []string) error { Verbosef("snapshot of %v at %s:\n", sn.Paths, sn.Time) - return printTree("", repo, *sn.Tree) + return printTree(string(filepath.Separator), repo, *sn.Tree) } From 039e81b04b8812463c03257bb293fb1eb44f6daa Mon Sep 17 00:00:00 2001 From: Pauline Middelink Date: Thu, 2 Mar 2017 23:30:56 +0100 Subject: [PATCH 2/3] Fix unit test, we need to check for absolute paths now. --- src/cmds/restic/integration_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cmds/restic/integration_test.go b/src/cmds/restic/integration_test.go index 477e8052a..0a819e7bb 100644 --- a/src/cmds/restic/integration_test.go +++ b/src/cmds/restic/integration_test.go @@ -516,23 +516,23 @@ func TestBackupExclude(t *testing.T) { testRunBackup(t, []string{datadir}, opts, gopts) snapshots, snapshotID := lastSnapshot(snapshots, loadSnapshotMap(t, gopts)) files := testRunLs(t, gopts, snapshotID) - Assert(t, includes(files, filepath.Join("testdata", "foo.tar.gz")), + Assert(t, includes(files, filepath.Join("/testdata", "foo.tar.gz")), "expected file %q in first snapshot, but it's not included", "foo.tar.gz") opts.Excludes = []string{"*.tar.gz"} testRunBackup(t, []string{datadir}, opts, gopts) snapshots, snapshotID = lastSnapshot(snapshots, loadSnapshotMap(t, gopts)) files = testRunLs(t, gopts, snapshotID) - Assert(t, !includes(files, filepath.Join("testdata", "foo.tar.gz")), + Assert(t, !includes(files, filepath.Join("/testdata", "foo.tar.gz")), "expected file %q not in first snapshot, but it's included", "foo.tar.gz") opts.Excludes = []string{"*.tar.gz", "private/secret"} testRunBackup(t, []string{datadir}, opts, gopts) snapshots, snapshotID = lastSnapshot(snapshots, loadSnapshotMap(t, gopts)) files = testRunLs(t, gopts, snapshotID) - Assert(t, !includes(files, filepath.Join("testdata", "foo.tar.gz")), + Assert(t, !includes(files, filepath.Join("/testdata", "foo.tar.gz")), "expected file %q not in first snapshot, but it's included", "foo.tar.gz") - Assert(t, !includes(files, filepath.Join("testdata", "private", "secret", "passwords.txt")), + Assert(t, !includes(files, filepath.Join("/testdata", "private", "secret", "passwords.txt")), "expected file %q not in first snapshot, but it's included", "passwords.txt") }) } From 5ecaaea90befb70613a9a37ff124cff62033f48b Mon Sep 17 00:00:00 2001 From: Pauline Middelink Date: Fri, 3 Mar 2017 11:14:39 +0100 Subject: [PATCH 3/3] Really use absolute pathnames, not all systems use /. --- src/cmds/restic/integration_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cmds/restic/integration_test.go b/src/cmds/restic/integration_test.go index 0a819e7bb..3c7533ac5 100644 --- a/src/cmds/restic/integration_test.go +++ b/src/cmds/restic/integration_test.go @@ -516,23 +516,23 @@ func TestBackupExclude(t *testing.T) { testRunBackup(t, []string{datadir}, opts, gopts) snapshots, snapshotID := lastSnapshot(snapshots, loadSnapshotMap(t, gopts)) files := testRunLs(t, gopts, snapshotID) - Assert(t, includes(files, filepath.Join("/testdata", "foo.tar.gz")), + Assert(t, includes(files, filepath.Join(string(filepath.Separator), "testdata", "foo.tar.gz")), "expected file %q in first snapshot, but it's not included", "foo.tar.gz") opts.Excludes = []string{"*.tar.gz"} testRunBackup(t, []string{datadir}, opts, gopts) snapshots, snapshotID = lastSnapshot(snapshots, loadSnapshotMap(t, gopts)) files = testRunLs(t, gopts, snapshotID) - Assert(t, !includes(files, filepath.Join("/testdata", "foo.tar.gz")), + Assert(t, !includes(files, filepath.Join(string(filepath.Separator), "testdata", "foo.tar.gz")), "expected file %q not in first snapshot, but it's included", "foo.tar.gz") opts.Excludes = []string{"*.tar.gz", "private/secret"} testRunBackup(t, []string{datadir}, opts, gopts) snapshots, snapshotID = lastSnapshot(snapshots, loadSnapshotMap(t, gopts)) files = testRunLs(t, gopts, snapshotID) - Assert(t, !includes(files, filepath.Join("/testdata", "foo.tar.gz")), + Assert(t, !includes(files, filepath.Join(string(filepath.Separator), "testdata", "foo.tar.gz")), "expected file %q not in first snapshot, but it's included", "foo.tar.gz") - Assert(t, !includes(files, filepath.Join("/testdata", "private", "secret", "passwords.txt")), + Assert(t, !includes(files, filepath.Join(string(filepath.Separator), "testdata", "private", "secret", "passwords.txt")), "expected file %q not in first snapshot, but it's included", "passwords.txt") }) }