git_remote_rename: propogate GIT_ENOTFOUND
diff --git a/src/remote.c b/src/remote.c
index d346fb3..c98c160 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -1677,7 +1677,7 @@ int git_remote_rename(git_strarray *out, git_repository *repo, const char *name,
assert(out && repo && name && new_name);
if ((error = git_remote_load(&remote, repo, name)) < 0)
- return -1;
+ return error;
if ((error = ensure_remote_name_is_valid(new_name)) < 0)
goto cleanup;
diff --git a/tests/network/remote/rename.c b/tests/network/remote/rename.c
index e1aea02..49929a4 100644
--- a/tests/network/remote/rename.c
+++ b/tests/network/remote/rename.c
@@ -200,6 +200,15 @@ void test_network_remote_rename__overwrite_ref_in_target(void)
git_branch_iterator_free(iter);
}
+void test_network_remote_rename__nonexistent_returns_enotfound(void)
+{
+ git_strarray problems = {0};
+
+ int err = git_remote_rename(&problems, _repo, "nonexistent", "renamed");
+
+ cl_assert_equal_i(GIT_ENOTFOUND, err);
+}
+
void test_network_remote_rename__symref_head(void)
{
int error;