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

Re: [PATCH] gitweb: prepare for repositories with packed refs.

From
Petr Baudis <pasky@suse.cz>
Date
Oct 7, 2006, 12:58 UTC
Message-ID
<20061007125802.GA20017@pasky.or.cz>
In-Reply-To
<7vzmc8tqqe.fsf@assigned-by-dhcp.cox.net>

Dear diary, on Sat, Oct 07, 2006 at 11:33:29AM CEST, I got a letter where Junio C Hamano <junkio@cox.net> said that...

Show 15 quoted lines
> When we introduced symref, "cat .git/HEAD" stopped being the way
> to read the value of the tip of the current branch, "echo
> $commit >.git/HEAD" stopped being the way to update it, and
> "rev-parse --verify HEAD" and "update-ref HEAD $commit" were
> introduced at the same time as the official alternatives to
> support both old and new implementations of .git/HEAD.
> 
> The way to find out which branch we are currently on used to be
> "readlink .git/HEAD"; that stopped to be true, and we introduced
> "symbolic-ref HEAD" as the official alternative to support both
> old and new implementation.
> 
> The way to see if a random symbolic link whose name happens to
> be HEAD is a symref has been to see if it points at a path that
> begins with "refs/".
Cogito does
	[ ! -s "$_git/HEAD" ] || { _git_head="$(git-symbolic-ref HEAD)"; _git_head="${_git_head#refs/heads/}"; }

in the common initialization code, so that cg-reset works even on repositories with broken HEAD. It hasn't been an issue in the past since HEAD as a dangling symlink indeed _has_ been broken HEAD in the past.

That said, at least cg-reset will indeed repair it:
	if ! [ -s "$_git/HEAD" ]; then
		rm -f "$_git/HEAD"
		# XXX: git-symbolic-ref is a weenie and won't do the job at this point.
		echo "ref: refs/heads/$_git_head" >"$_git/HEAD"
	fi
But it's still not nice.
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 6 in “gitweb: prepare for repositories with packed refs.”
  1. gitweb: prepare for repositories with packed refs.Junio C Hamano, Oct 3, 2006
  2. Petr BaudisOct 6, 2006
  3. Junio C HamanoOct 7, 2006
  4. Petr BaudisOct 7, 2006
  5. Junio C HamanoOct 7, 2006
  6. Jakub NarebskiOct 7, 2006

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.