snapshots: Make --json output [] instead of null when no snapshots

This commit is contained in:
Leo R. Lundgren
2020-10-05 13:04:24 +02:00
parent a23d90d270
commit 137d20a06a
2 changed files with 11 additions and 2 deletions

View File

@@ -298,7 +298,7 @@ type SnapshotGroup struct {
// printSnapshotsJSON writes the JSON representation of list to stdout.
func printSnapshotGroupJSON(stdout io.Writer, snGroups map[string]restic.Snapshots, grouped bool) error {
if grouped {
var snapshotGroups []SnapshotGroup
snapshotGroups := []SnapshotGroup{}
for k, list := range snGroups {
var key restic.SnapshotGroupKey
@@ -330,7 +330,7 @@ func printSnapshotGroupJSON(stdout io.Writer, snGroups map[string]restic.Snapsho
}
// Old behavior
var snapshots []Snapshot
snapshots := []Snapshot{}
for _, list := range snGroups {
for _, sn := range list {