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

Re: `git-rev-parse master` not referred to by any ref?

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 26, 2007, 21:26 UTC
Message-ID
<7vir72ng1n.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20070826140645.GC20243@fieldses.org>
"J. Bruce Fields" <bfields@fieldses.org> writes:
>> Oops, found it:
>> 
>> 	git$ cat .git/master
>> 	407c0c87e15b3cf60347f4fc0bcdb4d239de4163

It _might_ make it safer to refuse creating anything outside refs/ if the name does not contain or ends with "HEAD" (or perhaps names that have chars outside "[_A-Z]"), but that would restrict future tools that might want to have HEAD-like files, so I am a bit hesitant.

OTOH, a random file under .git/ does not count as a ref for the purposes of fsck/prune, so it may make sense to teach check_ref_format() about the same set of "special" names that can appear directly under .git without being in refs/ hierarchy (currently I think only "HEAD" and possibly "ORIG_HEAD" are in that set).

BTW, git-merge.sh and git-reset.sh should use "git update-ref ORIG_HEAD" instead of doing it by hand using "echo >$GIT_DIR/ORIG_HEAD".

Also, I *think* objects that are only reachable via ORIG_HEAD are not considered as reachable by fsck/prune --- we probably would want to fix this.

Previous: J. Bruce FieldsNext: Shawn O. Pearce
Message 4 of 6 in “`git-rev-parse master` not referred to by any ref?”
  1. J. Bruce FieldsAug 26, 2007
  2. J. Bruce FieldsAug 26, 2007
  3. J. Bruce FieldsAug 26, 2007
  4. Junio C HamanoAug 26, 2007
  5. Shawn O. PearceAug 26, 2007
  6. J. Bruce FieldsAug 26, 2007

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.