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

Getting 'git log' (or something else) to show me the relevant sub-graph?

From
Johan Herland <johan@herland.net>
Date
Apr 20, 2010, 14:49 UTC
Message-ID
<201004201649.31084.johan@herland.net>
Hi,
Consider the following (simplified) history:
---O---O---O---O---O---O---O---O---O---O---O---O---M2--H  <-- mainline
    \                                             /
     O---O---O---O---O---O---O---M1--D---E---F---G  <-- dev-branch
              \                 /
               O---O---A---B---C  <-- topic-branch

Now, assume that I have bisected my way through to 'A', and found that it introduces some bug. Now, I'm interested in visualizing the path that this bug "travelled" to get into "mainline", i.e. the following sub-graph:

                          --M2--H  <-- mainline
                           /
        --M1--D---E---F---G  <-- dev-branch
         /
A---B---C  <-- topic-branch
In other words, I'm interested in the following log (with decorations):

H (mainline) M2 G (dev-branch) F E D M1 C (topic-branch) B A

I have unsuccessfully dug through the 'git log' documentation to figure out if it can produce this log, so I'm now throwing the question to the almighty knowledge of the mailing list...

Here are some of my closest attempts, so far:
- git branch --contains A
	gives me "topic-branch", "dev-branch" and "mainline", which is
	relevant, but incomplete.
- git log --oneline --decorate --graph A^..mainline
	gives me a log/graph where I can search for A and then use the graph
	to trace the way back up to "mainline", but it still displays a lot of
	uninteresting commits (ancestors of M1 and M2) that I have to
	disregard. Although this is ok once in a while, the problem is common
	enough (and the real-world graphs complicated enough), that I'd like a
	better solution, if possible.

I guess what I'm looking for is something similar to --first-parent, except instead of the _first_ parent, it should follow the _relevant_ parent, as far as the relationship between A and "mainline" is concerned.

In set-theory terms I guess what I want is "that which is both an ancestor of H, and a descendant of A (inclusive)", but I don't know how to explain this to 'git log'.

Thanks for any help,
...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Next: Michael J Gruber
Message 1 of 11 in “Getting 'git log' (or something else) to show me the relevant sub-graph?”
  1. Johan HerlandApr 20, 2010
  2. Michael J GruberApr 20, 2010
  3. Junio C HamanoApr 20, 2010
  4. revision: --ancestry-pathJunio C Hamano, Apr 20, 2010
  5. Johan HerlandApr 21, 2010
  6. Johannes SixtApr 21, 2010
  7. Junio C HamanoApr 21, 2010
  8. revision: --ancestry-pathJunio C Hamano, Apr 21, 2010
  9. Johan HerlandApr 21, 2010
  10. Junio C HamanoApr 21, 2010
  11. Junio C HamanoApr 21, 2010

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.