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

Re: rev-list --parents --full-history + path: something's fishy

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
May 25, 2008, 21:30 UTC
Message-ID
<alpine.LFD.1.10.0805251424040.3081@woody.linux-foundation.org>
In-Reply-To
<200805252158.22514.johannes.sixt@telecom.at>
On Sun, 25 May 2008, Johannes Sixt wrote:
Show 8 quoted lines
> 
> But why does this:
> 
> $ git rev-list --full-history HEAD -- a
> B
> A
> 
> not list M (note the lack of --parents)?

Because when we don't ask for --parents, the whole problem is *much* simpler. The parent rewriting means that the history has to all "fit together". But when you don't need parenthood, then suddenly that doesn't matter at all - who cares if it fits together or not, when you can't *see* that it doesn't fit together anyway?

In this case, it's "simplify_commit()", and this piece of code in particular (note how it's even commented!):

		...
                /* Commit without changes? */
                if (commit->object.flags & TREESAME) {
                        /* drop merges unless we want parenthood */
                        if (!revs->rewrite_parents)
                                return commit_ignore;
		...

ie if we're looking at a commit that doesn't actually introduce any changes of its own (it took all the changes from at least _one_ of its parents - ie it got TREESAME set because the tree was identical to one of the parents), then if we don't have 'rewrite_parents' set, we just drop that commit, because it is uninteresting.

IOW, we dropped 'M' because there was no point in showing it: we know nobody refers to it (because no other commit will list it as a parent!), and the commit itself didn't actually introduce any changes (because all the changes came from 'B').

But we can *not* drop that merge commit when we do the parenthood tracking, because if we did so, we'd just have an "empty spot" in history (we have other commits that point to that emrge and list it as a parent).

Of course, in your trivial example, that didn't actually happen (because 'M' was the top commit), but try it with something more complex.

			Linus
Previous: Johannes Sixt
Message 9 of 9 in “rev-list --parents --full-history + path: something's fishy”
  1. Johannes SixtMay 24, 2008
  2. Linus TorvaldsMay 25, 2008
  3. Johannes SixtMay 25, 2008
  4. Linus TorvaldsMay 25, 2008
  5. Revert "filter-branch: subdirectory filter needs --full-history"Johannes Sixt, May 26, 2008
  6. David TweedMay 27, 2008
  7. Junio C HamanoMay 28, 2008
  8. Johannes SixtMay 25, 2008
  9. Linus TorvaldsMay 25, 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.