summaryrefslogtreecommitdiff
path: root/builtin-push.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2006-04-30 15:23:48 +0200
committerJunio C Hamano <junkio@cox.net>2006-05-02 01:03:02 -0700
commit97d4df0b29d262df291985aed486e226b43132d0 (patch)
tree68f89398bc706a14ab0550f07ef1200a812a15a9 /builtin-push.c
parent54eb2d3ff91bf7a914b6e1de9cf8f748d6a9ecb4 (diff)
downloadgit-97d4df0b29d262df291985aed486e226b43132d0.tar.gz
builtin-push: also ask config for remote information
Now you can store your remote information in the config file like this: [remote.upstream] url = me@company.com:the-project push = master:iceballs [jc: fixed up to adjust a different fix for Push: lines earlier.] Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-push.c')
-rw-r--r--builtin-push.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/builtin-push.c b/builtin-push.c
index 9a861b5afe..06d06ff310 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -115,6 +115,41 @@ static int get_remotes_uri(const char *repo, const char *uri[MAX_URI])
return n;
}
+static const char **config_uri;
+static const char *config_repo;
+static int config_repo_len;
+static int config_current_uri;
+static int config_get_refspecs;
+
+static int get_remote_config(const char* key, const char* value)
+{
+ if (!strncmp(key, "remote.", 7) &&
+ !strncmp(key + 7, config_repo, config_repo_len)) {
+ if (!strcmp(key + 7 + config_repo_len, ".url")) {
+ if (config_current_uri < MAX_URI)
+ config_uri[config_current_uri++] = strdup(value);
+ else
+ error("more than %d URL's specified, ignoring the rest", MAX_URI);
+ }
+ else if (config_get_refspecs &&
+ !strcmp(key + 7 + config_repo_len, ".push"))
+ add_refspec(strdup(value));
+ }
+ return 0;
+}
+
+static int get_config_remotes_uri(const char *repo, const char *uri[MAX_URI])
+{
+ config_repo_len = strlen(repo);
+ config_repo = repo;
+ config_current_uri = 0;
+ config_uri = uri;
+ config_get_refspecs = !refspec_nr;
+
+ git_config(get_remote_config);
+ return config_current_uri;
+}
+
static int get_branches_uri(const char *repo, const char *uri[MAX_URI])
{
const char *slash = strchr(repo, '/');
@@ -162,6 +197,10 @@ static int read_config(const char *repo, const char *uri[MAX_URI])
if (n > 0)
return n;
+ n = get_config_remotes_uri(repo, uri);
+ if (n > 0)
+ return n;
+
n = get_branches_uri(repo, uri);
if (n > 0)
return n;