From 1c3b37a1df39ec31b2ccd6c73996ce9a9e0abf28 Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Mon, 22 Mar 2021 14:39:32 +0100 Subject: gitaly-git2go: Return empty error when no changes When the tree before and after the cherry-pick are the same, it means there's nothing to commit. So in this case return an `EmptyError` instead of building the commit. --- internal/git2go/gob.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'internal/git2go') diff --git a/internal/git2go/gob.go b/internal/git2go/gob.go index 7c4ef0554..9f9ff97b4 100644 --- a/internal/git2go/gob.go +++ b/internal/git2go/gob.go @@ -31,6 +31,7 @@ var registeredTypes = map[interface{}]struct{}{ FileNotFoundError(""): {}, InvalidArgumentError(""): {}, HasConflictsError{}: {}, + EmptyError{}: {}, IndexError(""): {}, } @@ -62,6 +63,14 @@ func (err HasConflictsError) Error() string { return "could not apply due to conflicts" } +// EmptyError indicates the command, for example cherry-pick, did result in no +// changes, so the result is empty. +type EmptyError struct{} + +func (err EmptyError) Error() string { + return "could not apply because the result was empty" +} + // SerializableError returns an error that is Gob serializable. // Registered types are serialized directly. Unregistered types // are transformed in to an opaque error using their error message. -- cgit v1.2.3