# [PATCH 1/3] builtin-push: also ask config for remote information

1 messages from 2006-04-30 to 2006-04-30. Participants: Johannes Schindelin.
Thread: https://gitlist.dev/t/4009

## Johannes Schindelin, 2006-04-30 13:23

Subject: [PATCH 1/3] builtin-push: also ask config for remote information
Message-ID: <Pine.LNX.4.63.0604301520460.2646@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0604301520460.2646%40wbgn013.biozentrum.uni-wuerzburg.de

```

Now you can store your remote information in the config file like this:

[remote.upstream]
	url = me@company.com:the-project
	push = master:iceballs

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

	Obviously, this is on top of the patch to parse Pull: lines, too.

 builtin-push.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

e55eb69f6332087c45082e16ccbf4e510d721e29
diff --git a/builtin-push.c b/builtin-push.c
index 4e659f0..e3131ed 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -72,6 +72,36 @@ #define MAX_REFSPECS 10
 static int current_refspec = 0;
 static char *refspecs_[MAX_REFSPECS];
 
+static int repo_len = 0;
+static const char *repo_ = NULL;
+static int current_uri = 0;
+static const char **uri_;
+
+static int get_value(const char* key, const char* value)
+{
+	if (!strncmp(key, "remote.", 7) && !strncmp(key + 7, repo_, repo_len)) {
+		if (!strcmp(key + 7 + repo_len, ".url"))
+			uri_[current_uri++] = strdup(value);
+		else if (!strcmp(key + 7 + repo_len, ".push")
+				&& current_refspec < MAX_REFSPECS)
+			refspecs_[current_refspec++] = strdup(value);
+	}
+
+	return 0;
+}
+
+static int get_config_remotes_uri(const char *repo, const char *uri[MAX_URI])
+{
+	repo_len = strlen(repo);
+	repo_ = repo;
+	current_uri = 0;
+	uri_ = uri;
+
+	git_config(get_value);
+
+	return current_uri;
+}
+
 static int get_remotes_uri(const char *repo, const char *uri[MAX_URI])
 {
 	int n = 0;
@@ -153,6 +183,9 @@ static int get_uri(const char *repo, con
 	if (*repo != '/') {
 		current_refspec = 0;
 
+		n = get_config_remotes_uri(repo, uri);
+		if (n > 0)
+			return n;
 		n = get_remotes_uri(repo, uri);
 		if (n > 0)
 			return n;
-- 
1.3.1.g38c00-dirty

```
