1

I have a huge history and I'm only interested in given commits (say I have a list of 10 commit sha1s). How to start gitk, that is

gitk --SOMETHING sha123 sha234 sha345 ...

so that only the given commits are rendered in gitk? I know that I can do similar thing with

git log --oneline --no-walk sha123 sha234 sha345 ...

but git log --no-walk doesn't want to take --graph. In addition, I'd prefer gitk so that I can view each commit a bit easier. If one or more of the above commits include merge with one or more of the given commits, I'd like to see graph lines between the commits. Basically I'm asking for something like --simplify-everything-but-listed-commits.

Another good solution would be if somebody can point out how to run gitk like

gitk --simplify-by-decoration --never-simplify-listed-commits sha123 sha234 sha345 ...

because that would render some extra but still process whole history for real. Of course, the flag --never-simplify-listed-commits doesn't exist. The --simplify-by-decoration ends up NOT rendering any of the given SHA-1s because those do not match any branch or tag.

I also tried hacks such as

gitk sha123..sha123 sha234..sha234 ...

because it seems that gitk is willing to render only given commits with that syntax. However, that only seems to work only for one range at a time. I'd much prefer rendering all commits in a single view.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Mikko Rantalainen
  • 14,132
  • 10
  • 74
  • 112
  • You have to specify the range of commits, not the commit only: `gitk sha123~1..sha123 sha234~1..sha234 ...`. – terrorrussia-keeps-killing Jan 22 '21 at 15:44
  • @LeGEC oh, that's true. Is it possible somehow? – terrorrussia-keeps-killing Jan 22 '21 at 15:57
  • @fluffy : what wouldn't work is : `sha123~..sha123` expands to `^sha123 sha123`. If `sha234` is an ancestor of `sha123`, it will be discarded by `^sha123`. And similarly if `sha123` is an ancestor of `sha234`. – LeGEC Jan 22 '21 at 15:57
  • 3
    The gitk code is a tcl/tk script. I'd suggest finding the source, editing it to make it understand the `--no-walk` option, and submitting that to its maintainer (it's included with Git but maintained outside Git). Note that gitk spins up windows while forking off a `git rev-list` in the background. It then reads streaming output from rev-list and updates its windows as it goes. – torek Jan 23 '21 at 01:01
  • 1
    It seems that if I remove the `--no-walk` from the list of filtered options in the `gitk` Tcl/Tk script `gitk --no-walk sha123 sha234 sha345 ...` does indeed work correctly even when the listed commits are in mixed order. See `less -p no-walk $(which gitk)` for correct location. The comment however says that "These cause our parsing of git log's output to fail [...] so ignore them". – Mikko Rantalainen Jan 23 '21 at 12:14
  • Interesting. I remember seeing the filtering in the tcl script; I never tried taking it out entirely though. – torek Jan 24 '21 at 00:25

1 Answers1

1

One way could be to create a reference for each of these commits, and use the --decorate-refs= option of git log.

For example :

  • create one branch dec/{xx} reference pointing at each of the 10 commits,
  • run :
git log --all --oneline --graph --decorate-refs=refs/heads/dec --simplify-by-decoration
  • delete all branches under dec/
LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • Pretty nice workaround. With a suitable script that makes sure that the prefix is not previously taken (e.g. using `dec{timestamp}/xx` instead of `dec/xx` if `dec` is already taken) this solution should be pretty stable. – Mikko Rantalainen Jan 29 '21 at 17:15
  • If you don't want to mess with branches, you can use any ref : `git update-ref refs/d/{xx}` / `git update-ref -d refs/d/{xx}` – LeGEC Jan 29 '21 at 21:23