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

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

From
Junio C Hamano <junkio@cox.net>
Date
Oct 7, 2006, 09:33 UTC
Message-ID
<7vzmc8tqqe.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20061006154059.GQ20017@pasky.or.cz>
Petr Baudis <pasky@suse.cz> writes:
Show 8 quoted lines
>> Running -e "$dir/HEAD" to guess if $dir is a git repository does
>> not give us the right answer anymore in such a case.
>
> I think this is a wrong answer to this problem - I guess Cogito's going
> to be confused by HEAD a dangling symlink as well and I'll bet there's
> more places where this will give us trouble. Having HEAD a dangling
> symlink is just wrong and git-pack-refs --prune is buggy if it causes
> that.
I disagree.

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/".

The user has a repository that uses symbolic link HEAD, and is asking to use pack-refs and is also asking to prune loose refs that no longer are needed, but definitely is NOT asking to convert the repository to use symref HEAD. The repository after "pack-refs --prune" works perfectly well with symbolic link HEAD, so doing that unasked-for conversion is unnecessary.

And the thing is, if the repository is actively being used, it is a non issue -- recent-enough git would create a symref by default. The only place where it matters in practice are public git repositories initialized using git before mid November last year, and has never switched the "current branch" ever since using git of newer vintage.

Previous: Petr BaudisNext: Petr Baudis
Message 3 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.