{"thread":{"id":"2311","subject":"[PATCH] git-clone: do not forget to create origin branch.","startedAt":"2005-11-02T06:20:56Z","lastAt":"2005-11-02T06:20:56Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"10992","messageId":"7v8xw71sfr.fsf@assigned-by-dhcp.cox.net","threadId":"2311","inReplyTo":null,"subject":"[PATCH] git-clone: do not forget to create origin branch.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-02T06:20:56Z","receivedAt":"2005-11-02T06:20:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The newly cloned repository by default had .git/remotes/origin\nset up to track the remote master to origin, but forgot to\ncreate the origin branch ourselves.  Also it hardcoded the\nassumption that the remote HEAD points at \"master\", which may\nnot always be true.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n * Objections?\n\n git-clone.sh |   15 +++++++++++----\n 1 files changed, 11 insertions(+), 4 deletions(-)\n\napplies-to: 9c030fed625268c19d7f0838b26f742745b36085\ne125c1a717bb732319596d8b792a67c2b7b15ef7\ndiff --git a/git-clone.sh b/git-clone.sh\nindex 18e692a..c27a913 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -196,10 +196,17 @@ cd $D || exit\n \n if test -f \".git/HEAD\"\n then\n-\tmkdir -p .git/remotes || exit\n-\techo >.git/remotes/origin \\\n-\t\"URL: $repo\n-Pull: master:origin\"\n+\thead_points_at=`git-symbolic-ref HEAD`\n+\tcase \"$head_points_at\" in\n+\trefs/heads/*)\n+\t\thead_points_at=`expr \"$head_points_at\" : 'refs/heads/\\(.*\\)'`\n+\t\tmkdir -p .git/remotes &&\n+\t\techo >.git/remotes/origin \\\n+\t\t\"URL: $repo\n+Pull: $head_points_at:origin\"\n+\t\tcp \".git/refs/heads/$head_points_at\" .git/refs/heads/origin\n+\tesac\n+\n \tcase \"$no_checkout\" in\n \t'')\n \t\tgit checkout\n---\n0.99.9.GIT\n"}]}