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

[PATCH Cogito] Use git-update-ref for updating the HEAD

From
Jonas Fonseca <fonseca@diku.dk>
Date
Oct 2, 2005, 10:12 UTC
Message-ID
<20051002101224.GA9219@diku.dk>

Conditionally make git-update-ref check the old head. For this to succeed for the initial commit, cg-init should not touch .git/refs/heads/master, and the touching seems to be redundant anyway, so remove it.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>

--- commit b41f8cafc556233613412ff3545e3507202b666a tree 9e2c5d8d467acc27d7c866c908990d7de44478f9 parent b06f2a707963c8712f7a6bbd4b89bae758bcf92a author Jonas Fonseca <fonseca@diku.dk> Thu, 29 Sep 2005 15:09:06 +0200 committer Jonas Fonseca <fonseca@stud1-9.itu.dk> Thu, 29 Sep 2005 15:09:06 +0200

 cg-Xlib   |    2 +-
 cg-commit |    2 +-
 cg-init   |    1 -
 3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -246,7 +246,7 @@ tree_timewarp()
 	fi
 
 	git-read-tree -m "$branch" || die "$branch: bad commit"
-	[ "$no_head_update" ] || echo "$branch" > $_git/HEAD
+	[ "$no_head_update" ] || git-update-ref HEAD "$branch"
 
 	# Kill gone files
 	git-diff-tree -z -r $base $branch | xargs -0 bash -c '
diff --git a/cg-commit b/cg-commit
--- a/cg-commit
+++ b/cg-commit
@@ -420,7 +420,7 @@ fi
 
 if [ "$newhead" ]; then
 	echo "Committed as $newhead."
-	echo $newhead >$_git/HEAD
+	git-update-ref HEAD $newhead $oldhead
 	[ "$merging" ] && rm $_git/merging $_git/merging-sym $_git/merge-base
 	rm -f "$_git/commit-ignore"
 
diff --git a/cg-init b/cg-init
--- a/cg-init
+++ b/cg-init
@@ -48,7 +48,6 @@ done
 cleanup_trap "rm -rf $_git"
 
 git-init-db
-touch $_git/refs/heads/master
 
 git-read-tree # Seed the dircache
 if ! [ "$no_initial_commit" ]; then
-- 
Jonas Fonseca
Next: Jonas Fonseca
Message 1 of 2 in “Use git-update-ref for updating the HEAD”
  1. Use git-update-ref for updating the HEADJonas Fonseca, Oct 2, 2005
  2. Use git-{update,symbolic}-ref for updating HEADJonas Fonseca, Oct 8, 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.