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

Re: Make 'git fsck' complain about non-commit branches

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jan 16, 2008, 01:01 UTC
Message-ID
<alpine.LFD.1.00.0801151654050.2806@woody.linux-foundation.org>
In-Reply-To
<7v8x2qd2hu.fsf@gitster.siamese.dyndns.org>
On Tue, 15 Jan 2008, Junio C Hamano wrote:
Show 5 quoted lines
> 
> So far, the plumbing level did not care much about the Porcelain
> convention, such as refs/heads and refs/remotes (you seem to
> have forgot) are about "branches" and must point at commit
> objects.

Yeah. I'm not sure this is all a great idea, but I think they are correct (and no, "refs/remotes/" would *not* have been correct).

The "be more careful about parents" patch (builtin-commit.c) is unquestionably a good idea - those things really *have* to be commits from a plumbing standpoint.

The other ones follow the same rules: "HEAD" really does need to be a commit, since that will otherwise cause breakage (not just for "git commit", but for "git clone" too). The same is true of "git checkout" and "refs/heads/" - if a "refs/heads/" ref isn't a commit, switching branches will get confused!

So now git-fsck verifies things that would confuse git itself. But that's also why refs/remotes/* aren't checked for being commits, and really a remote branch is very *different* from a local branch - because those things would never be used for a commit chain by the native git commands, so git itself shouldn't care.

We've clearly moved a lot of the porcelain layer into git internals, and maybe this went too far, but I suspect not. You can still do whatever the heck you want from a porcelain angle, it just has to follow the (fairly lax) rules that core git itself does expect.

		Linus
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 5 in “Make 'git fsck' complain about non-commit branches”
  1. Linus TorvaldsJan 16, 2008
  2. Junio C HamanoJan 16, 2008
  3. Linus TorvaldsJan 16, 2008
  4. Junio C HamanoJan 16, 2008
  5. Linus TorvaldsJan 16, 2008

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.