git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-clone-pack: do not silently overwrite an existing branch 'origin'
@ 2005-12-22 17:59 Johannes Schindelin
  2005-12-22 21:12 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2005-12-22 17:59 UTC (permalink / raw)
  To: git, junkio


When cloning a repository which already contains a branch called 'origin',
do not silently overwrite it with the remote 'master' ref.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

	This happened to me with a project I track via git-cvsimport.
	The clone strangely suffered a time warp ;-)

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

f0d4ef72573488410a1e8eb0198e347630d6e2c9
diff --git a/git-clone.sh b/git-clone.sh
index 280cc2e..e988964 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -204,6 +204,10 @@ then
 	head_points_at=`git-symbolic-ref HEAD`
 	case "$head_points_at" in
 	refs/heads/*)
+		if test -e .git/refs/heads/origin; then
+			chmod a-w .git/refs/heads/origin
+			echo "Warning: branch 'origin' exists already"
+		fi
 		head_points_at=`expr "$head_points_at" : 'refs/heads/\(.*\)'`
 		mkdir -p .git/remotes &&
 		echo >.git/remotes/origin \
-- 
1.0.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-12-22 22:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-22 17:59 [PATCH] git-clone-pack: do not silently overwrite an existing branch 'origin' Johannes Schindelin
2005-12-22 21:12 ` Junio C Hamano
2005-12-22 22:37   ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).