{"thread":{"id":"5653","subject":"[PATCH] Fetch: default remote repository from config","startedAt":"2006-09-22T23:26:46Z","lastAt":"2006-09-22T23:26:46Z","messageCount":1,"participants":["Santi Béjar"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"27429","messageId":"878xkba3ex.fsf@gmail.com","threadId":"5653","inReplyTo":null,"subject":"[PATCH] Fetch: default remote repository from config","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-22T23:26:46Z","receivedAt":"2006-09-22T23:26:46Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\nIf in branch \"foo\" and this in config:\n\n[branch \"foo\"]\n        remote=bar\n\n\"git fetch\" = \"git fetch bar\"\n\"git  pull\" = \"git pull  bar\"\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n Documentation/config.txt |    3 +++\n git-fetch.sh             |   11 ++++++-----\n 2 files changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex bb2fbc3..fa20e28 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -119,6 +119,9 @@ apply.whitespace::\n \tTells `git-apply` how to handle whitespaces, in the same way\n \tas the '--whitespace' option. See gitlink:git-apply[1].\n \n+branch.<name>.remote::\n+\tWhen in branch <name>, it tells `git pull` which remote to fetch.\n+\n pager.color::\n \tA boolean to enable/disable colored output when the pager is in\n \tuse (default is true).\ndiff --git a/git-fetch.sh b/git-fetch.sh\nindex 09a5d6c..e3b8f26 100755\n--- a/git-fetch.sh\n+++ b/git-fetch.sh\n@@ -68,11 +68,12 @@ done\n \n case \"$#\" in\n 0)\n-\ttest -f \"$GIT_DIR/branches/origin\" ||\n-\t\ttest -f \"$GIT_DIR/remotes/origin\" ||\n-\t\t\tgit-repo-config --get remote.origin.url >/dev/null ||\n-\t\t\t\tdie \"Where do you want to fetch from today?\"\n-\tset origin ;;\n+\tcurr_branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')\n+\torigin=$(git-repo-config --get \"branch.$curr_branch.remote\")\n+\torigin=${origin:-origin}\n+\ttest -n \"$(get_remote_url ${origin})\" ||\n+\t\tdie \"Where do you want to fetch from today?\"\n+\tset x $origin ; shift ;;\n esac\n \n remote_nick=\"$1\"\n-- \n1.4.2.1.g4b5cd\n"}]}