git/list[1] front-page[2] threads[3] people[4] search[5] about
 

How is working on arbitrary remote heads supposed to work in Cogito (+ PATCH)?

From
JWJosef Weidendorfer <josef.weidendorfer@gmx.de>
Date
Jul 27, 2005, 12:58 UTC
Message-ID
<200507271458.43063.Josef.Weidendorfer@gmx.de>
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
Next: Junio C Hamano
Message 1 of 41 in “How is working on arbitrary remote heads supposed to work in Cogito (+ PATCH)?”
  1. Josef WeidendorferJul 27, 2005
  2. Junio C HamanoJul 28, 2005
  3. Petr BaudisJul 28, 2005
  4. Johannes SchindelinJul 28, 2005
  5. Petr BaudisJul 28, 2005
  6. Johannes SchindelinJul 28, 2005
  7. Petr BaudisJul 28, 2005
  8. Junio C HamanoJul 28, 2005
  9. Johannes SchindelinJul 28, 2005
  10. Ryan AndersonJul 28, 2005
  11. Johannes SchindelinJul 28, 2005
  12. Petr BaudisJul 28, 2005
  13. Johannes SchindelinJul 28, 2005
  14. Matthias UrlichsJul 28, 2005
  15. Johannes SchindelinJul 28, 2005
  16. Petr BaudisJul 29, 2005
  17. Junio C HamanoJul 29, 2005
  18. Petr BaudisJul 29, 2005
  19. Junio C HamanoJul 29, 2005
  20. Petr BaudisJul 29, 2005
  21. Junio C HamanoJul 29, 2005
  22. Petr BaudisJul 29, 2005
  23. Johannes SchindelinJul 29, 2005
  24. Petr BaudisJul 29, 2005
  25. Johannes SchindelinJul 29, 2005
  26. Petr BaudisJul 29, 2005
  27. Junio C HamanoJul 30, 2005
  28. Matthias UrlichsJul 29, 2005
  29. Junio C HamanoJul 30, 2005
  30. Carl BaldwinAug 13, 2005
  31. Junio C HamanoAug 13, 2005
  32. Carl BaldwinAug 15, 2005
  33. Johannes SchindelinAug 15, 2005
  34. Josef WeidendorferJul 29, 2005
  35. Matthias UrlichsJul 28, 2005
  36. Petr BaudisJul 29, 2005
  37. Josef WeidendorferJul 28, 2005
  38. Unnamed branchesPetr Baudis, Jul 28, 2005
  39. Junio C HamanoJul 28, 2005
  40. Petr BaudisJul 28, 2005
  41. Petr BaudisJul 28, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.