Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bccb36e

Browse files
author
Vicent Marti
committed
Merge pull request libgit2#2389 from arthurschreiber/arthur/set-error-when-no-remote-found
Remote: Set an error when a remote cannot be found.
2 parents eb27d29 + d723dbe commit bccb36e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/remote.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
403403

404404
if (!optional_setting_found) {
405405
error = GIT_ENOTFOUND;
406+
giterr_set(GITERR_CONFIG, "Remote '%s' does not exist.", name);
406407
goto cleanup;
407408
}
408409

tests/network/remote/remotes.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ void test_network_remote_remotes__pushurl(void)
6060
cl_assert(git_remote_pushurl(_remote) == NULL);
6161
}
6262

63+
void test_network_remote_remotes__error_when_not_found(void)
64+
{
65+
git_remote *r;
66+
cl_git_fail_with(git_remote_load(&r, _repo, "does-not-exist"), GIT_ENOTFOUND);
67+
68+
cl_assert(giterr_last() != NULL);
69+
cl_assert(giterr_last()->klass == GITERR_CONFIG);
70+
}
71+
6372
void test_network_remote_remotes__error_when_no_push_available(void)
6473
{
6574
git_remote *r;

0 commit comments

Comments
 (0)