{"thread":{"id":"1994","subject":"[PATCH Cogito] Use git-update-ref for updating the HEAD","startedAt":"2005-10-02T10:12:24Z","lastAt":"2005-10-08T16:57:23Z","messageCount":2,"participants":["Jonas Fonseca"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"9603","messageId":"20051002101224.GA9219@diku.dk","threadId":"1994","inReplyTo":null,"subject":"[PATCH Cogito] Use git-update-ref for updating the HEAD","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-10-02T10:12:24Z","receivedAt":"2005-10-02T10:12:24Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Conditionally make git-update-ref check the old head. For this to succeed\nfor the initial commit, cg-init should not touch .git/refs/heads/master,\nand the touching seems to be redundant anyway, so remove it.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n\n---\ncommit b41f8cafc556233613412ff3545e3507202b666a\ntree 9e2c5d8d467acc27d7c866c908990d7de44478f9\nparent b06f2a707963c8712f7a6bbd4b89bae758bcf92a\nauthor Jonas Fonseca <fonseca@diku.dk> Thu, 29 Sep 2005 15:09:06 +0200\ncommitter Jonas Fonseca <fonseca@stud1-9.itu.dk> Thu, 29 Sep 2005 15:09:06 +0200\n\n cg-Xlib   |    2 +-\n cg-commit |    2 +-\n cg-init   |    1 -\n 3 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/cg-Xlib b/cg-Xlib\n--- a/cg-Xlib\n+++ b/cg-Xlib\n@@ -246,7 +246,7 @@ tree_timewarp()\n \tfi\n \n \tgit-read-tree -m \"$branch\" || die \"$branch: bad commit\"\n-\t[ \"$no_head_update\" ] || echo \"$branch\" > $_git/HEAD\n+\t[ \"$no_head_update\" ] || git-update-ref HEAD \"$branch\"\n \n \t# Kill gone files\n \tgit-diff-tree -z -r $base $branch | xargs -0 bash -c '\ndiff --git a/cg-commit b/cg-commit\n--- a/cg-commit\n+++ b/cg-commit\n@@ -420,7 +420,7 @@ fi\n \n if [ \"$newhead\" ]; then\n \techo \"Committed as $newhead.\"\n-\techo $newhead >$_git/HEAD\n+\tgit-update-ref HEAD $newhead $oldhead\n \t[ \"$merging\" ] && rm $_git/merging $_git/merging-sym $_git/merge-base\n \trm -f \"$_git/commit-ignore\"\n \ndiff --git a/cg-init b/cg-init\n--- a/cg-init\n+++ b/cg-init\n@@ -48,7 +48,6 @@ done\n cleanup_trap \"rm -rf $_git\"\n \n git-init-db\n-touch $_git/refs/heads/master\n \n git-read-tree # Seed the dircache\n if ! [ \"$no_initial_commit\" ]; then\n\n-- \nJonas Fonseca\n"},{"id":"9833","messageId":"20051008165723.GA28414@diku.dk","threadId":"1994","inReplyTo":"20051002101224.GA9219@diku.dk","subject":"[PATCH Cogito] Use git-{update,symbolic}-ref for updating HEAD","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-10-08T16:57:23Z","receivedAt":"2005-10-08T16:57:23Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Conditionally make git-update-ref check the old head. For this to succeed\nfor the initial commit, cg-init should not touch .git/refs/heads/master,\nand the touching seems to be redundant anyway, so remove it.\n\nThis should make Cogito mostly work on cygwin.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n\n---\n\nThis is an incremental update to make Cogito handle symbolic refs.\n\n I am not sure whether the change from using '[ -L .git/HEAD ]' to using\n'[ -e .git/HEAD ]' is the thing to do. And I haven't used it so much\nyet; did a few commit and so on. And the tests fails do to local cloning\nnot working yet (git-local-fetch needs to be fixed).\n\n Makefile                        |    2 +-\n cg-Xlib                         |    4 ++--\n cg-commit                       |    4 ++--\n cg-init                         |    1 -\n cg-object-id                    |    2 +-\n\n---\n\ndiff --git a/Makefile b/Makefile\nindex f0a0590..9eacade 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -35,7 +35,7 @@ all: cogito\n cogito: $(GEN_SCRIPT)\n \n ifneq (,$(wildcard .git))\n-GIT_HEAD=.git/HEAD\n+GIT_HEAD=.git/$(shell git-symbolic-ref HEAD)\n GIT_HEAD_ID=\" \\($(shell cat $(GIT_HEAD))\\)\"\n endif\n cg-version: $(VERSION) $(GIT_HEAD) Makefile\ndiff --git a/cg-Xlib b/cg-Xlib\nindex b27e8b9..dcf9aa3 100755\n--- a/cg-Xlib\n+++ b/cg-Xlib\n@@ -246,7 +246,7 @@ tree_timewarp()\n \tfi\n \n \tgit-read-tree -m \"$branch\" || die \"$branch: bad commit\"\n-\t[ \"$no_head_update\" ] || echo \"$branch\" > $_git/HEAD\n+\t[ \"$no_head_update\" ] || git-update-ref HEAD \"$branch\"\n \n \t# Kill gone files\n \tgit-diff-tree -z -r $base $branch | xargs -0 bash -c '\n@@ -471,7 +471,7 @@ if [ ! \"$_git_repo_unneeded\" ]; then\n \t       exit 1\n \tfi\n \t_git_head=master\n-\t[ -L \"$_git/HEAD\" ] && _git_head=\"$(basename \"$(readlink \"$_git/HEAD\")\")\"\n+\t[ -e \"$_git/HEAD\" ] && _git_head=\"$(basename \"$(git-symbolic-ref HEAD)\")\"\n \t[ -s \"$_git/head-name\" ] && _git_head=\"$(cat \"$_git/head-name\")\"\n fi\n \ndiff --git a/cg-commit b/cg-commit\nindex 4345bd5..6024f17 100755\n--- a/cg-commit\n+++ b/cg-commit\n@@ -396,7 +396,7 @@ fi\n \n oldhead=\n if [ -s \"$_git/HEAD\" ]; then\n-\toldhead=$(cat $_git/HEAD)\n+\toldhead=$(git-symbolic-ref HEAD)\n \toldheadstr=\"-p $oldhead\"\n fi\n \n@@ -420,7 +420,7 @@ fi\n \n if [ \"$newhead\" ]; then\n \techo \"Committed as $newhead.\"\n-\techo $newhead >$_git/HEAD\n+\tgit-update-ref HEAD $newhead $oldhead \n \t[ \"$merging\" ] && rm $_git/merging $_git/merging-sym $_git/merge-base\n \trm -f \"$_git/commit-ignore\"\n \ndiff --git a/cg-init b/cg-init\nindex 570c83e..65faf84 100755\n--- a/cg-init\n+++ b/cg-init\n@@ -48,7 +48,6 @@ done\n cleanup_trap \"rm -rf $_git\"\n \n git-init-db\n-touch $_git/refs/heads/master\n \n git-read-tree # Seed the dircache\n if ! [ \"$no_initial_commit\" ]; then\ndiff --git a/cg-object-id b/cg-object-id\nindex 2ae9420..5c03626 100755\n--- a/cg-object-id\n+++ b/cg-object-id\n@@ -53,7 +53,7 @@ normalize_id()\n \tfi\n \n \tif [ ! \"$id\" ] || [ \"$id\" = \"this\" ] || [ \"$id\" = \"HEAD\" ]; then\n-\t\tread id < \"$_git/HEAD\"\n+\t\tread id < \"$_git/$(git-symbolic-ref HEAD)\"\n \n \telif [ -r \"$_git/refs/tags/$id\" ]; then\n \t\tread id < \"$_git/refs/tags/$id\"\n-- \nJonas Fonseca\n"}]}