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

Re: What's the meaning of `parenthood' in git commits?

From
Linus Torvalds <torvalds@osdl.org>
Date
Nov 8, 2006, 00:58 UTC
Message-ID
<Pine.LNX.4.64.0611071644430.3667@g5.osdl.org>
In-Reply-To
<878ximbwm3.fsf@hades.wkstn.nix>
On Wed, 8 Nov 2006, Nix wrote:
> 
> [ Nix explains what he's doing now with SCCS ]: you may be
> sick now.
Wow. You've got some strange setup there, Nix.
> After all that setup, my question's simple. Does a `parent' in git
> terminology simply mean `this commit was derived in some way from the
> commit listed here'?

Well, strictly speaking, git doesn't itself assign much any real meaning to "parent" at all. It has the obvious meanings:

 - the parent pointers act as reachability graph edges (so fsck cares 
   about it a lot, of course)
 - listing the "log" of a commit will show everything reachable from that 
   commit and it's parents, of course (with the commit date-stamp being 
   used as a "ordering" when having multiple choices of commits to show)
 - it has the obvious meanings for the "revision arithmetic", ie revision 
   name parsing (ie "commit~3^2")
 - parenthood will be used to show the diff ("git show", "git log -p" and 
   friends)
 - the "merge-base" algorithms obviously use it to find the most recent 
   common ancestor, and that in turn impacts the normal merge strategies, 
   of course.

so parenthood does obviously have a number of very specific technical meanings for different programs, but at the same time, no, git doesn't really "care". You can happily generate your own parenthood if you want to, and git will just continue to follow the above rules.

> If so, I suppose I can list heads/some-change-foo as one parent on these 
> merge commits, even though the `merging' mechanism is so odd that I 
> expect to be pelted with rotten vegetables as soon as I post this.
Yeah, git won't care. If you screw up parenthood, you have a few problems:
 - the diffs may look really strange. In particular, if you list multiple 
   parents, the git "diff" functions will all just assume that it's a 
   merge, and a "git show" will start showing the combined diff (which is 
   usually empty).
   So if you end up having multiple parents, not because it was "really" a 
   merge, but because you use the other parent pointer to point to some 
   "source" for the patch, things like "git log -p" won't give nice output 
   any more. You need to manually ask for the diff with something like
	# show diff from second parent
	git diff commit^2..commit
   instead.
 - listing too _few_ parents is potentially more serious, if you have 
   reachability issues (ie you wanted to keep the other source around, but 
   since you didn't list it as a parent, git won't know that it had 
   anything to do with your commit, so it may be pruned away unless you 
   have some other way to reach it)

but if you just have a really strange merge algorithm, and the _data_ associated with the parents is "surprising" from the standpoint of the default merge, git really won't care at all.

Your usage does sound a bit strange.
Previous: Jakub NarebskiNext: Nix
Message 3 of 7 in “What's the meaning of `parenthood' in git commits?”
  1. NixNov 8, 2006
  2. Jakub NarebskiNov 8, 2006
  3. Linus TorvaldsNov 8, 2006
  4. NixNov 8, 2006
  5. NixNov 8, 2006
  6. Junio C HamanoNov 8, 2006
  7. NixNov 8, 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.