mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 11:28:54 +00:00
Merge pull request #2984 from restic/snapshots-json
snapshots: Make --json output [] instead of null when no snapshots
This commit is contained in:
commit
6001b45bf7
9
changelog/unreleased/issue-2979
Normal file
9
changelog/unreleased/issue-2979
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Bugfix: Make snapshots --json output [] instead of null when no snapshots
|
||||||
|
|
||||||
|
Restic previously output `null` instead of `[]` for the `--json snapshots`
|
||||||
|
command, when there were no snapshots in the repository. This caused some
|
||||||
|
minor problems when parsing the output, but is now fixed such that `[]` is
|
||||||
|
output when the list of snapshots is empty.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/issues/2979
|
||||||
|
https://github.com/restic/restic/pull/2984
|
@ -298,7 +298,7 @@ type SnapshotGroup struct {
|
|||||||
// printSnapshotsJSON writes the JSON representation of list to stdout.
|
// printSnapshotsJSON writes the JSON representation of list to stdout.
|
||||||
func printSnapshotGroupJSON(stdout io.Writer, snGroups map[string]restic.Snapshots, grouped bool) error {
|
func printSnapshotGroupJSON(stdout io.Writer, snGroups map[string]restic.Snapshots, grouped bool) error {
|
||||||
if grouped {
|
if grouped {
|
||||||
var snapshotGroups []SnapshotGroup
|
snapshotGroups := []SnapshotGroup{}
|
||||||
|
|
||||||
for k, list := range snGroups {
|
for k, list := range snGroups {
|
||||||
var key restic.SnapshotGroupKey
|
var key restic.SnapshotGroupKey
|
||||||
@ -330,7 +330,7 @@ func printSnapshotGroupJSON(stdout io.Writer, snGroups map[string]restic.Snapsho
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Old behavior
|
// Old behavior
|
||||||
var snapshots []Snapshot
|
snapshots := []Snapshot{}
|
||||||
|
|
||||||
for _, list := range snGroups {
|
for _, list := range snGroups {
|
||||||
for _, sn := range list {
|
for _, sn := range list {
|
||||||
|
Loading…
Reference in New Issue
Block a user