0

I would like to get a similar view to gitk --all -- <path> that also includes all branch heads. By default, gitk invoked like that selects all commits that affect the given path and displays a simplified graph that includes only those commits. If some of those commits happen to be branch heads or to correspond to tags, the branches or tags are drawn as well. That is basically half of what I want. In addition to the commits that affect the given path, I would like the graph to also include all the commits that correspond to branch heads.

This kind of graphic representation would tell me which of the commits that affect the given path are accessible/included on each branch.

One possible way of doing this would be to get a list of all commits that affect the given path (for example using git rev-list) and the list of all commits that are referenced by branch heads and pass the combined list to gitk to get a graphical representation. But gitk doesn't seem to support being passed a list of specific commits to include.

Radu Rendec
  • 479
  • 5
  • 6

1 Answers1

1

Add --simplify-by-decoration, and use git log to specify which exact decorations you want, e.g.

git log --graph --decorate-refs=refs/heads/* --oneline --branches \
        -m --name-status --simplify-by-decoration -- path/to/file.1 e/t/cetera
jthill
  • 55,082
  • 5
  • 77
  • 137
  • Awesome, this is exactly what I was looking for! In case anyone else finds @jthill's excellent answer useful, `--decorate-refs=refs/heads/*` can be replaced with `--remotes --decorate-refs-exclude='refs/tags/*'` to include both local and remote branches instead of only local branches. – Radu Rendec Aug 20 '21 at 02:12
  • Maybe this is a separate question altogether, but is there any way to render the output graphically? For example, export to an image file. – Radu Rendec Aug 20 '21 at 02:17
  • Fixing up `gitk` to honor the decorate exclusions should be a pretty straightforward enhancement, I don't know of an existing tool that'll do it already though. – jthill Aug 20 '21 at 03:35