SHA256
1
0
forked from pool/restic
restic/restic-switch-to-pre-1.8-sort.Stable-API.patch
Aleksa Sarai cfbdb3f10f Accepting request 564009 from home:cyphar:restic
- Switch away from using build.go, and instead manually build with "go". This
  allows us to build with the older Go compilers present in Leap, as well as to
  build the binary as PIC and dynamic.
- Add generated man pages.
- In order to build with older Go compilers, add a patch.
  + restic-switch-to-pre-1.8-sort.Stable-API.patch

OBS-URL: https://build.opensuse.org/request/show/564009
OBS-URL: https://build.opensuse.org/package/show/Archiving/restic?expand=0&rev=2
2018-01-13 16:47:05 +00:00

47 lines
1.8 KiB
Diff

From 5d18f341c3191f7e472faa2659a9c973629a31a5 Mon Sep 17 00:00:00 2001
From: Aleksa Sarai <cyphar@cyphar.com>
Date: Sun, 14 Jan 2018 03:31:07 +1100
Subject: [PATCH] restic: switch to pre-1.8 sort.Stable API
This allows us to build restic with older Go versions. It's a bit odd
they decided to implement things this way, given that the old
sort.Interface code still exists in the repo...
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
---
cmd/restic/cmd_snapshots.go | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/cmd/restic/cmd_snapshots.go b/cmd/restic/cmd_snapshots.go
index 5dfb45e9729e..9acf8c0a9d44 100644
--- a/cmd/restic/cmd_snapshots.go
+++ b/cmd/restic/cmd_snapshots.go
@@ -106,9 +106,7 @@ func newFilterLastSnapshotsKey(sn *restic.Snapshot) filterLastSnapshotsKey {
// they will be joined and treated as one item.
func FilterLastSnapshots(list restic.Snapshots) restic.Snapshots {
// Sort the snapshots so that the newer ones are listed first
- sort.SliceStable(list, func(i, j int) bool {
- return list[i].Time.After(list[j].Time)
- })
+ sort.Stable(list)
var results restic.Snapshots
seen := make(map[filterLastSnapshotsKey]bool)
@@ -124,11 +122,8 @@ func FilterLastSnapshots(list restic.Snapshots) restic.Snapshots {
// PrintSnapshots prints a text table of the snapshots in list to stdout.
func PrintSnapshots(stdout io.Writer, list restic.Snapshots, compact bool) {
-
- // always sort the snapshots so that the newer ones are listed last
- sort.SliceStable(list, func(i, j int) bool {
- return list[i].Time.Before(list[j].Time)
- })
+ // Always sort the snapshots so that the newer ones are listed last
+ sort.Stable(sort.Reverse(list))
// Determine the max widths for host and tag.
maxHost, maxTag := 10, 6
--
2.15.1