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

Re: [PATCH] Re: keeping remote repo checked out?

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Nov 29, 2005, 06:02 UTC
Message-ID
<Pine.LNX.4.64.0511282337170.25300@iabervon.org>
In-Reply-To
<Pine.LNX.4.64.0511282029290.3177@g5.osdl.org>
On Mon, 28 Nov 2005, Linus Torvalds wrote:
Show 23 quoted lines
> On Mon, 28 Nov 2005, Daniel Barkalow wrote:
> > 
> > I was planning to keep it in .git (instead of .git/refs/...), because it's 
> > information about the working tree, not properly part of the repository. 
> > It's like MERGE_HEAD in being about what the user is in the middle of.
> 
> That's fine.
> 
> However, your patch isn't.
> 
> Your patch just creates this eternal confusion of "why is HEAD different 
> from CHECKED_OUT". 
> 
> It's really easy to do what you want to do _without_ any tool changes:
> 
> 	git-rev-parse HEAD > .git/CHECKED_OUT
> 	rm .git/HEAD
> 	ln -s refs/heads/../../CHECKED_OUT .git/HEAD
> 
> and you're done. No tool changes necessary.
> 
> Now "HEAD" always points to the checked-out thing, but a "git clone" won't 
> ever actually clone your CHECKED_OUT branch.

But CHECKED_OUT isn't a branch. The whole point of it is that you stay on some real branch, so you can actually use the tools to affect the repository (i.e., the things under refs/). The reason to keep CHECKED_OUT is so that you can tell if the branch you're on changes out from under you.

For example, I want to have a repository where I push into the "production" branch, and I want to be able to get these changes in the working tree that the repository is in. If I have HEAD point to refs/heads/production, git doesn't know any more what's in the working tree, so it can't do the two-way merge. If I have HEAD point to CHECKED_OUT, git doesn't know any more what I want to get, so it can't do the two-way merge. That is, what I want to have work is:

  server$ git checkout production
  work$ git push server:production
  server$ git checkout

and this should leave the working tree on server with the changes pushed from work. Currently, I have to make sure server *isn't* tracking the branch I care about when the push happens, so that it doesn't lose track of its state, and then switch to the branch to get the changes, and copy the branch to a new branch, and switch to that so the next branch won't mess up the state.

HEAD is a symbolic ref to the ref in the repository that is the current branch. CHECKED_OUT is a ref to the hash that's in the working tree. Usually they match, because usually nothing is changing current branch without changing the working tree (or making the current branch match changes in the working tree), but the point of the patch is to respond sensibly to cases where this stops being true, because those can actually be part of desirable usage patterns.

	-Daniel
*This .sig left intentionally blank*
Previous: Linus TorvaldsNext: Junio C Hamano
Message 14 of 25 in “keeping remote repo checked out?”
  1. James CloosNov 28, 2005
  2. Junio C HamanoNov 28, 2005
  3. Petr BaudisNov 28, 2005
  4. Junio C HamanoNov 28, 2005
  5. Petr BaudisNov 28, 2005
  6. Junio C HamanoNov 28, 2005
  7. Linus TorvaldsNov 28, 2005
  8. Daniel BarkalowNov 29, 2005
  9. Linus TorvaldsNov 29, 2005
  10. Daniel BarkalowNov 29, 2005
  11. Linus TorvaldsNov 29, 2005
  12. Re: keeping remote repo checked out?Daniel Barkalow, Nov 29, 2005
  13. Linus TorvaldsNov 29, 2005
  14. Daniel BarkalowNov 29, 2005
  15. Junio C HamanoNov 29, 2005
  16. Daniel BarkalowNov 29, 2005
  17. Junio C HamanoNov 29, 2005
  18. Matthias UrlichsNov 29, 2005
  19. Junio C HamanoNov 29, 2005
  20. Daniel BarkalowNov 29, 2005
  21. Junio C HamanoNov 29, 2005
  22. Daniel BarkalowNov 29, 2005
  23. Matthias UrlichsNov 29, 2005
  24. James CloosDec 1, 2005
  25. Junio C HamanoDec 1, 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.