[PATCH] git-clone-pack: do not silently overwrite an existing branch 'origin'

From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Date: 2005-12-23 04:59:30
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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Fri Dec 23 05:00:05 2005

This archive was generated by hypermail 2.1.8 : 2005-12-23 05:00:12 EST