From 9fb70f378ace77bf20ec67c5bce044114a0e0f93 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Mon, 7 May 2012 10:57:34 +0200 Subject: [PATCH] remote: make git_remote_load() return GIT_ENOTFOUND when the remote url cannot be retrieved from the config file --- src/remote.c | 4 +--- tests-clar/network/remotes.c | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/remote.c b/src/remote.c index a30841427..6a1390dba 100644 --- a/src/remote.c +++ b/src/remote.c @@ -112,10 +112,8 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name) goto cleanup; } - if (git_config_get_string(config, git_buf_cstr(&buf), &val) < 0) { - error = -1; + if ((error = git_config_get_string(config, git_buf_cstr(&buf), &val)) < 0) goto cleanup; - } remote->repo = repo; remote->url = git__strdup(val); diff --git a/tests-clar/network/remotes.c b/tests-clar/network/remotes.c index 766a461b9..f03d983c3 100644 --- a/tests-clar/network/remotes.c +++ b/tests-clar/network/remotes.c @@ -153,3 +153,8 @@ void test_network_remotes__list(void) git_config_free(cfg); } + +void test_network_remotes__loading_a_missing_remote_returns_ENOTFOUND(void) +{ + cl_assert_equal_i(GIT_ENOTFOUND, git_remote_load(&_remote, _repo, "just-left-few-minutes-ago")); +}