remote: use constants for well-known names
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
diff --git a/src/clone.c b/src/clone.c
index 9dfc22c..211288c 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -51,7 +51,7 @@ static int create_tracking_branch(git_repository *repo, const git_oid *target, c
if (!git_buf_printf(&remote, "branch.%s.remote", name) &&
!git_buf_printf(&merge, "branch.%s.merge", name) &&
!git_buf_printf(&merge_target, GIT_REFS_HEADS_DIR "%s", name) &&
- !git_config_set_string(cfg, git_buf_cstr(&remote), "origin") &&
+ !git_config_set_string(cfg, git_buf_cstr(&remote), GIT_REMOTE_ORIGIN) &&
!git_config_set_string(cfg, git_buf_cstr(&merge), git_buf_cstr(&merge_target))) {
retcode = 0;
}
@@ -150,7 +150,7 @@ static int setup_remotes_and_fetch(git_repository *repo,
if (!fetch_stats) fetch_stats = &dummy_stats;
/* Create the "origin" remote */
- if (!git_remote_add(&origin, repo, "origin", origin_url)) {
+ if (!git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, origin_url)) {
/* Connect and download everything */
if (!git_remote_connect(origin, GIT_DIR_FETCH)) {
if (!git_remote_download(origin, &bytes, fetch_stats)) {
diff --git a/src/remote.h b/src/remote.h
index b8bb2c5..05073db 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -13,6 +13,8 @@
#include "transport.h"
#include "repository.h"
+#define GIT_REMOTE_ORIGIN "origin"
+
struct git_remote {
char *name;
char *url;
diff --git a/src/repository.c b/src/repository.c
index 1641129..1b49228 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -19,6 +19,7 @@
#include "refs.h"
#include "filter.h"
#include "odb.h"
+#include "remote.h"
#define GIT_FILE_CONTENT_PREFIX "gitdir:"
@@ -1095,7 +1096,7 @@ static int repo_init_create_origin(git_repository *repo, const char *url)
int error;
git_remote *remote;
- if (!(error = git_remote_add(&remote, repo, "origin", url))) {
+ if (!(error = git_remote_add(&remote, repo, GIT_REMOTE_ORIGIN, url))) {
error = git_remote_save(remote);
git_remote_free(remote);
}