git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 30, 2006, 13:23 UTC
Message-ID
<Pine.LNX.4.63.0604301520460.2646@wbgn013.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
Message 1 of 1 in “builtin-push: also ask config for remote information”
  1. 1/3 builtin-push: also ask config for remote informationJohannes Schindelin, Apr 30, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.