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

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Johannes Schindelin
Date: Thursday, December 22, 2005 - 3:37 pm

Hi,

On Thu, 22 Dec 2005, Junio C Hamano wrote:


As I said, I use git to keep track of a few CVS projects. I like to fetch 
all branches, one being the upstream branch, so that I can compare what 
changes not yet in upstream.


So don't.


---

[PATCH] git-clone: Support changing the origin branch with -o

Earlier, git-clone stored upstream's master in the branch named 'origin',
possibly overwriting an existing such branch.

Now you can change it by calling git-clone with '-o <other_name>'.

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

---

	Totally untested, but obviously correct :-)

	It still overwrites any existing ref of the same name silently.

 git-clone.sh |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/git-clone.sh b/git-clone.sh
index 280cc2e..87ad477 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -67,6 +67,7 @@ use_local=no
 local_shared=no
 no_checkout=
 upload_pack=
+origin=origin
 while
 	case "$#,$1" in
 	0,*) break ;;
@@ -75,6 +76,8 @@ while
         *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) 
           local_shared=yes; use_local=yes ;;
 	*,-q|*,--quiet) quiet=-q ;;
+	1,-o) usage;;
+	*,-o) origin="$2"; shift;;
 	1,-u|1,--upload-pack) usage ;;
 	*,-u|*,--upload-pack)
 		shift
@@ -208,14 +211,14 @@ then
 		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 &&
+Pull: $head_points_at:$origin" &&
+		cp ".git/refs/heads/$head_points_at" .git/refs/heads/$origin &&
 		find .git/refs/heads -type f -print |
 		while read ref
 		do
 			head=`expr "$ref" : '.git/refs/heads/\(.*\)'` &&
 			test "$head_points_at" = "$head" ||
-			test "origin" = "$head" ||
+			test "$origin" = "$head" ||
 			echo "Pull: ${head}:${head}"
 		done >>.git/remotes/origin
 	esac
-
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
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] git-clone-pack: do not silently overwrite an exist ..., Johannes Schindelin, (Thu Dec 22, 10:59 am)
Re: [PATCH] git-clone-pack: do not silently overwrite an e ..., Johannes Schindelin, (Thu Dec 22, 3:37 pm)