{"thread":{"id":"4010","subject":"[PATCH 2/3] fetch, pull: ask config for remote information","startedAt":"2006-04-30T13:24:03Z","lastAt":"2006-04-30T13:24:03Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"19284","messageId":"Pine.LNX.4.63.0604301523500.2646@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4010","inReplyTo":null,"subject":"[PATCH 2/3] fetch, pull: ask config for remote information","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-04-30T13:24:03Z","receivedAt":"2006-04-30T13:24:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nNow you can say\n\n[remote.junio]\n\turl = git://git.kernel.org/pub/scm/git/git.git\n\tpull = next:next\n\nin your .git/config.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n git-parse-remote.sh |   55 +++++++++++++++++++++++++++++++++++++++++++++++----\n 1 files changed, 51 insertions(+), 4 deletions(-)\n\n5a1cf349639823183fce287be9f809d797f2cd84\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex c9b899e..8ce57c8 100755\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -4,13 +4,43 @@ # git-ls-remote could be called from out\n # this would fail in that case and would issue an error message.\n GIT_DIR=$(git-rev-parse --git-dir 2>/dev/null) || :;\n \n+if [ -d \"$GIT_DIR\"/remotes -a \"$GIT_REWRITE_REMOTES\" = true ]; then\n+\techo \"Rewriting $GIT_DIR/remotes\" >&2\n+\terror=0\n+\t# rewrite into config\n+\t{\n+\t\tcd \"$GIT_DIR\"/remotes\n+\t\tls | while read f; do\n+\t\t\tname=$(echo -n \"$f\" | tr -c \"A-Za-z0-9\" \".\")\n+\t\t\tsed -n \\\n+\t\t\t-e \"s/^URL: /remote.$name.url . /p\" \\\n+\t\t\t-e \"s/^Pull: /remote.$name.pull ^$ /p\" \\\n+\t\t\t-e \"s/^Push: /remote.$name.push ^$ /p\" \\\n+\t\t\t< \"$f\"\n+\t\tdone\n+\t\techo done\n+\t} | while read key regex value; do\n+\t\tcase $key in\n+\t\tdone)\n+\t\t\tif [ $error = 0 ]; then\n+\t\t\t\tmv \"$GIT_DIR\"/remotes \"$GIT_DIR\"/remotes.old\n+\t\t\tfi ;;\n+\t\t*)\n+\t\t\tgit-repo-config $key \"$value\" $regex || error=1 ;;\n+\t\tesac\n+\tdone\n+fi\n+\n get_data_source () {\n \tcase \"$1\" in\n \t*/*)\n \t\t# Not so fast.\tThis could be the partial URL shorthand...\n \t\ttoken=$(expr \"z$1\" : 'z\\([^/]*\\)/')\n \t\tremainder=$(expr \"z$1\" : 'z[^/]*/\\(.*\\)')\n-\t\tif test -f \"$GIT_DIR/branches/$token\"\n+\t\tif test \"$(git-repo-config --get \"remote.$token.url\")\"\n+\t\tthen\n+\t\t\techo config-partial\n+\t\telif test -f \"$GIT_DIR/branches/$token\"\n \t\tthen\n \t\t\techo branches-partial\n \t\telse\n@@ -18,7 +48,10 @@ get_data_source () {\n \t\tfi\n \t\t;;\n \t*)\n-\t\tif test -f \"$GIT_DIR/remotes/$1\"\n+\t\tif test \"$(git-repo-config --get \"remote.$1.url\")\"\n+\t\tthen\n+\t\t\techo config\n+\t\telif test -f \"$GIT_DIR/remotes/$1\"\n \t\tthen\n \t\t\techo remotes\n \t\telif test -f \"$GIT_DIR/branches/$1\"\n@@ -35,6 +68,15 @@ get_remote_url () {\n \tcase \"$data_source\" in\n \t'')\n \t\techo \"$1\" ;;\n+\tconfig-partial)\n+\t\ttoken=$(expr \"z$1\" : '\\([^/]*\\)/')\n+\t\tremainder=$(expr \"z$1\" : '[^/]*/\\(.*\\)')\n+\t\turl=$(git-repo-config --get \"remote.$token.url\")\n+\t\techo \"$url/$remainder\"\n+\t\t;;\n+\tconfig)\n+\t\tgit-repo-config --get \"remote.$1.url\"\n+\t\t;;\n \tremotes)\n \t\tsed -ne '/^URL: */{\n \t\t\ts///p\n@@ -56,8 +98,10 @@ get_remote_url () {\n get_remote_default_refs_for_push () {\n \tdata_source=$(get_data_source \"$1\")\n \tcase \"$data_source\" in\n-\t'' | branches | branches-partial)\n+\t'' | config-partial | branches | branches-partial)\n \t\t;; # no default push mapping, just send matching refs.\n+\tconfig)\n+\t\tgit-repo-config --get-all \"remote.$1.push\" ;;\n \tremotes)\n \t\tsed -ne '/^Push: */{\n \t\t\ts///p\n@@ -111,8 +155,11 @@ # Returns list of src: (no store), or sr\n get_remote_default_refs_for_fetch () {\n \tdata_source=$(get_data_source \"$1\")\n \tcase \"$data_source\" in\n-\t'' | branches-partial)\n+\t'' | config-partial | branches-partial)\n \t\techo \"HEAD:\" ;;\n+\tconfig)\n+\t\tcanon_refs_list_for_fetch \\\n+\t\t\t$(git-repo-config --get-all \"remote.$1.pull\") ;;\n \tbranches)\n \t\tremote_branch=$(sed -ne '/#/s/.*#//p' \"$GIT_DIR/branches/$1\")\n \t\tcase \"$remote_branch\" in '') remote_branch=master ;; esac\n-- \n1.3.1.g38c00-dirty\n"}]}