{"thread":{"id":"4009","subject":"[PATCH 1/3] builtin-push: also ask config for remote information","startedAt":"2006-04-30T13:23:48Z","lastAt":"2006-04-30T13:23:48Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"19283","messageId":"Pine.LNX.4.63.0604301520460.2646@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4009","inReplyTo":null,"subject":"[PATCH 1/3] builtin-push: also ask config for remote information","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-04-30T13:23:48Z","receivedAt":"2006-04-30T13:23:48Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nNow you can store your remote information in the config file like this:\n\n[remote.upstream]\n\turl = me@company.com:the-project\n\tpush = master:iceballs\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n\tObviously, this is on top of the patch to parse Pull: lines, too.\n\n builtin-push.c |   33 +++++++++++++++++++++++++++++++++\n 1 files changed, 33 insertions(+), 0 deletions(-)\n\ne55eb69f6332087c45082e16ccbf4e510d721e29\ndiff --git a/builtin-push.c b/builtin-push.c\nindex 4e659f0..e3131ed 100644\n--- a/builtin-push.c\n+++ b/builtin-push.c\n@@ -72,6 +72,36 @@ #define MAX_REFSPECS 10\n static int current_refspec = 0;\n static char *refspecs_[MAX_REFSPECS];\n \n+static int repo_len = 0;\n+static const char *repo_ = NULL;\n+static int current_uri = 0;\n+static const char **uri_;\n+\n+static int get_value(const char* key, const char* value)\n+{\n+\tif (!strncmp(key, \"remote.\", 7) && !strncmp(key + 7, repo_, repo_len)) {\n+\t\tif (!strcmp(key + 7 + repo_len, \".url\"))\n+\t\t\turi_[current_uri++] = strdup(value);\n+\t\telse if (!strcmp(key + 7 + repo_len, \".push\")\n+\t\t\t\t&& current_refspec < MAX_REFSPECS)\n+\t\t\trefspecs_[current_refspec++] = strdup(value);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int get_config_remotes_uri(const char *repo, const char *uri[MAX_URI])\n+{\n+\trepo_len = strlen(repo);\n+\trepo_ = repo;\n+\tcurrent_uri = 0;\n+\turi_ = uri;\n+\n+\tgit_config(get_value);\n+\n+\treturn current_uri;\n+}\n+\n static int get_remotes_uri(const char *repo, const char *uri[MAX_URI])\n {\n \tint n = 0;\n@@ -153,6 +183,9 @@ static int get_uri(const char *repo, con\n \tif (*repo != '/') {\n \t\tcurrent_refspec = 0;\n \n+\t\tn = get_config_remotes_uri(repo, uri);\n+\t\tif (n > 0)\n+\t\t\treturn n;\n \t\tn = get_remotes_uri(repo, uri);\n \t\tif (n > 0)\n \t\t\treturn n;\n-- \n1.3.1.g38c00-dirty\n"}]}