Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: git@vger.kernel.org
Subject: [PATCH] git-clone: do not forget to create origin branch.
Date: Tue, 01 Nov 2005 22:20:56 -0800	[thread overview]
Message-ID: <7v8xw71sfr.fsf@assigned-by-dhcp.cox.net> (raw)

The newly cloned repository by default had .git/remotes/origin
set up to track the remote master to origin, but forgot to
create the origin branch ourselves.  Also it hardcoded the
assumption that the remote HEAD points at "master", which may
not always be true.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---

 * Objections?

 git-clone.sh |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

applies-to: 9c030fed625268c19d7f0838b26f742745b36085
e125c1a717bb732319596d8b792a67c2b7b15ef7
diff --git a/git-clone.sh b/git-clone.sh
index 18e692a..c27a913 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -196,10 +196,17 @@ cd $D || exit
 
 if test -f ".git/HEAD"
 then
-	mkdir -p .git/remotes || exit
-	echo >.git/remotes/origin \
-	"URL: $repo
-Pull: master:origin"
+	head_points_at=`git-symbolic-ref HEAD`
+	case "$head_points_at" in
+	refs/heads/*)
+		head_points_at=`expr "$head_points_at" : 'refs/heads/\(.*\)'`
+		mkdir -p .git/remotes &&
+		echo >.git/remotes/origin \
+		"URL: $repo
+Pull: $head_points_at:origin"
+		cp ".git/refs/heads/$head_points_at" .git/refs/heads/origin
+	esac
+
 	case "$no_checkout" in
 	'')
 		git checkout
---
0.99.9.GIT

                 reply	other threads:[~2005-11-02  6:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v8xw71sfr.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox