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

Skip to content

Commit 4bb8708

Browse files
committed
Merge pull request libgit2#2683 from libgit2/cmn/remote-unify
remote: unify the creation code
2 parents 873eb89 + a68e217 commit 4bb8708

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

src/remote.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -207,34 +207,15 @@ static int ensure_remote_doesnot_exist(git_repository *repo, const char *name)
207207
int git_remote_create(git_remote **out, git_repository *repo, const char *name, const char *url)
208208
{
209209
git_buf buf = GIT_BUF_INIT;
210-
git_remote *remote = NULL;
211210
int error;
212211

213-
if ((error = ensure_remote_name_is_valid(name)) < 0)
214-
return error;
215-
216-
if ((error = ensure_remote_doesnot_exist(repo, name)) < 0)
217-
return error;
218-
219212
if (git_buf_printf(&buf, "+refs/heads/*:refs/remotes/%s/*", name) < 0)
220213
return -1;
221214

222-
if (create_internal(&remote, repo, name, url, git_buf_cstr(&buf)) < 0)
223-
goto on_error;
224-
215+
error = git_remote_create_with_fetchspec(out, repo, name, url, git_buf_cstr(&buf));
225216
git_buf_free(&buf);
226217

227-
if (git_remote_save(remote) < 0)
228-
goto on_error;
229-
230-
*out = remote;
231-
232-
return 0;
233-
234-
on_error:
235-
git_buf_free(&buf);
236-
git_remote_free(remote);
237-
return -1;
218+
return error;
238219
}
239220

240221
int git_remote_create_with_fetchspec(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch)

0 commit comments

Comments
 (0)