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

Re: Bootstrapping into git, commit gripes at me

From
Linus Torvalds <torvalds@osdl.org>
Date
Jul 12, 2005, 01:43 UTC
Message-ID
<Pine.LNX.4.58.0507111833380.17536@g5.osdl.org>
In-Reply-To
<Pine.LNX.4.58.0507111646000.17536@g5.osdl.org>
On Mon, 11 Jul 2005, Linus Torvalds wrote:
>
> No, git-checkout-script _shouldn't_ have done that. It will do the 
> read-tree on the tag (which will do the right thing), but it won't change 
> the HEAD itself.

In preparation of actually updating the HEAD, I just made "git checkout" verify that it only checks out a commit, not a tree tag or something like that. Too late for Marc, but next time around a "git checkout v2.6.11" will result in

	[torvalds@g5 linux]$ git checkout v2.6.11
	error: Object 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c is a tree, not a commit
	Needed a single revision

That's not exactly _obvious_ either, but hey, it's at least a half-way readable and understandable error, and it's obviously correct to somebody who knows how git works.

That still leaves the question about what to do when you do
	git checkout v2.6.12

which _is_ a valid operation. Right now it will "check out" that tag, in the sense that it will make the working tree correspond to v2.6.12, but it won't actually touch HEAD at all. The question is, what _should_ it do to head?

Should it just reset HEAD to point to .git/refs/master, and then write the commit ID to it? That may actually sometimes be exactly what you want, and at least it will result in a consistent state (ie the next commit will have the right parent). On the other hand, it will blow away whatever the old "master" branch contained, and thus likely leave an unreachable commit.

On the other hand, creating a new branch might be a but surprising to people: "But I just wanted to check it out". But as far as I can see, it's the only safe thing to do, and it has the advantage that you can then go back to the old state with a simple "git checkout master".

But what about the branch name? Should we just ask the user? Together with a flag, like

	git checkout -b new-branch v2.6.12

for somebody who wants to specify the branch name? Or should we pick a random name and add a helper function to rename a branch later?

Opinions?
Previous: Linus TorvaldsNext: Marc Singer
Message 7 of 33 in “Bootstrapping into git, commit gripes at me”
  1. Marc SingerJul 8, 2005
  2. Linus TorvaldsJul 9, 2005
  3. Marc SingerJul 11, 2005
  4. Junio C HamanoJul 11, 2005
  5. Junio C HamanoJul 11, 2005
  6. Linus TorvaldsJul 12, 2005
  7. Linus TorvaldsJul 12, 2005
  8. Marc SingerJul 12, 2005
  9. Linus TorvaldsJul 12, 2005
  10. Linus TorvaldsJul 12, 2005
  11. Linus TorvaldsJul 12, 2005
  12. Marc SingerJul 12, 2005
  13. Linus TorvaldsJul 12, 2005
  14. Marc SingerJul 12, 2005
  15. Petr BaudisJul 12, 2005
  16. Junio C HamanoJul 12, 2005
  17. Matthias UrlichsJul 12, 2005
  18. Petr BaudisJul 24, 2005
  19. Junio C HamanoJul 24, 2005
  20. Linus TorvaldsJul 12, 2005
  21. Petr BaudisAug 12, 2005
  22. Junio C HamanoJul 12, 2005
  23. Linus TorvaldsJul 12, 2005
  24. Junio C HamanoJul 12, 2005
  25. Linus TorvaldsJul 12, 2005
  26. Marc SingerJul 12, 2005
  27. Daniel BarkalowJul 12, 2005
  28. Linus TorvaldsJul 11, 2005
  29. Marc SingerJul 9, 2005
  30. Matthias UrlichsJul 9, 2005
  31. Petr BaudisJul 10, 2005
  32. Marc SingerJul 9, 2005
  33. Junio C HamanoJul 9, 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.