if I clone a remote head other than master via Cogito with

        cg-clone host:path#remoteHead,

work on this branch, and try to push back my changes with


I get the error

        "pushing to a different head not supported yet".

As far as I can see, there is no support in core GIT to make this ever work 
(at least with get-send-packs), as "git-send-pack" only updates a set of 
heads with the same name both locally and remote.

I suppose the best would be to always keep the same head names in cloned 
repositories - it seems to be easier to handle for users. Perhaps the only 
exception would be "master", as one probably would like to pull masters of 
different remote repositories into a local one (without really working on 

Thus, what about the following: Each time a remote head other than master is 
cloned, a head with the same name is created locally which is an alias to the 
local master. This way, cg-push almost works out of the box. Following patch 
implements this behavior.


diff --git a/cg-clone b/cg-clone
--- a/cg-clone
+++ b/cg-clone
@@ -69,5 +69,12 @@ cp $_git/refs/heads/origin $_git/refs/he
 git-read-tree HEAD
 git-checkout-cache -a
 git-update-cache --refresh

 echo "Cloned to $dir/ (origin $location available as branch \"origin\")"
+if echo "$location" | grep -q "#" ; then
+       rembranch=$(echo "$location" | sed -e "s/.*#//")
+       (cd $_git/refs/heads; ln -s master "$rembranch")
+       echo "Remote head \"$rbranch\" locally available as alias for 
diff --git a/cg-push b/cg-push
--- a/cg-push
+++ b/cg-push
@@ -28,17 +28,18 @@ uri=$(cat "$_git/branches/$name" 2>/dev/

 if echo "$uri" | grep -q '#'; then
        rembranch=$(echo $uri | cut -d '#' -f 2)
        uri=$(echo $uri | cut -d '#' -f 1)
-       die "pushing to a different head not supported yet"
+        [ -s $_git/refs/heads/$rembranch ] || (cd $_git/refs/heads;ln -s 
master $rembranch)
+        [ $(readlink $_git/refs/heads/$rembranch) = "master" ] || \
+          die "can not push to remote head \"$rembranch\""

 if echo "$uri" | grep -q "^http://";; then
        die "pushing over HTTP not supported yet"
 elif echo "$uri" | grep -q "^git+ssh://"; then
        git-send-pack "$(echo "$uri" | sed 
's#^git+ssh://\([^/]*\)\(/.*\)$#\1:\2#')" $rembranch
-elif echo "$uri" | grep -q ":"; then
+elif echo "$uri" | grep -q "^rsync://"; then
        die "pushing over rsync not supported"
        git-send-pack "$uri" $rembranch
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to