Git development
 help / color / mirror / Atom feed
* How is working on arbitrary remote heads supposed to work in Cogito (+ PATCH)?
@ 2005-07-27 12:58 Josef Weidendorfer
  2005-07-28  1:32 ` Junio C Hamano
  2005-07-28 12:08 ` Petr Baudis
  0 siblings, 2 replies; 41+ messages in thread
From: Josef Weidendorfer @ 2005-07-27 12:58 UTC (permalink / raw)
  To: git

Hi,

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

	cg-push,

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 
them).

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.

Josef

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 \"master\""
+fi
+
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/

 rembranch=master
 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\""
 fi

 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"
 else
        git-send-pack "$uri" $rembranch
 fi

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

end of thread, other threads:[~2005-08-15 23:56 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-27 12:58 How is working on arbitrary remote heads supposed to work in Cogito (+ PATCH)? Josef Weidendorfer
2005-07-28  1:32 ` Junio C Hamano
2005-07-28 12:08 ` Petr Baudis
2005-07-28 13:07   ` Johannes Schindelin
2005-07-28 15:35     ` Petr Baudis
2005-07-28 15:56       ` Johannes Schindelin
2005-07-28 16:18         ` Petr Baudis
2005-07-28 16:52           ` Junio C Hamano
2005-07-28 17:32             ` Johannes Schindelin
2005-07-28 18:45               ` Ryan Anderson
2005-07-28 18:51                 ` Johannes Schindelin
2005-07-28 18:39             ` Petr Baudis
2005-07-28 18:49               ` Johannes Schindelin
2005-07-28 19:47                 ` Matthias Urlichs
2005-07-28 20:14                   ` Johannes Schindelin
2005-07-29  7:11                     ` Petr Baudis
2005-07-29  2:24               ` Junio C Hamano
2005-07-29  7:06                 ` Petr Baudis
2005-07-29  7:48                   ` Junio C Hamano
2005-07-29  8:10                     ` Petr Baudis
2005-07-29  8:54                       ` Junio C Hamano
2005-07-29  9:40                         ` Petr Baudis
2005-07-29 10:57                           ` Johannes Schindelin
2005-07-29 11:13                             ` Petr Baudis
2005-07-29 12:26                               ` Johannes Schindelin
2005-07-29 12:28                                 ` Petr Baudis
2005-07-30  2:11                                   ` Junio C Hamano
2005-07-29 20:40                         ` Matthias Urlichs
2005-07-30 22:16                         ` Junio C Hamano
2005-08-13  4:11                       ` Carl Baldwin
2005-08-13  7:48                         ` Junio C Hamano
2005-08-15 16:23                           ` Carl Baldwin
2005-08-15 23:55                           ` Johannes Schindelin
2005-07-29  9:10                     ` Josef Weidendorfer
2005-07-28 21:13           ` Matthias Urlichs
2005-07-29  7:14             ` Petr Baudis
2005-07-28 18:53         ` Josef Weidendorfer
2005-07-28 19:19           ` Unnamed branches Petr Baudis
2005-07-28 16:14       ` How is working on arbitrary remote heads supposed to work in Cogito (+ PATCH)? Junio C Hamano
2005-07-28 16:23         ` Petr Baudis
2005-07-28 15:35   ` Petr Baudis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox