1

I have tried gitk $(git log -S" extreemly rare " --pretty=format:%h), as this answer suggests but gitk shows all commits in addition to the search results (if I can add anything to a universal set)

Initially, this came from this answer, that recommended gitk --all $(git log -S" rare text" --pretty=format:%h). I was advised to remove --all but this does not have any effect.

Community
  • 1
  • 1
Val
  • 1
  • 8
  • 40
  • 64

2 Answers2

2

Because gitk --all includes all branch heads, after which you're (maybe) adding a few more things to include. So the end result is for gitk to show you everything that's currently reachable from any branch head, including the (possibly empty) set of search results.

In the link you cite, what is being added to the --all is a set of dangling commits (i.e. not reachable by any branch head), so the end result is to add more than what gitk --all would show, not limit it.

Community
  • 1
  • 1
twalberg
  • 59,951
  • 11
  • 89
  • 84
  • Thanks. Do you mean that there are no ways to visualize the search result? – Val Sep 05 '13 at 20:44
  • No - if you want just the search result, leave out the `--all`; i.e. `gitk $(git log .....)`. If the search turns up empty, that may not be quite what you want, though, so you might be better off checking for empty search results first - something like `results=$(git log ....); [[ -z "${results}" ]] && gitk ${results}`. – twalberg Sep 05 '13 at 21:04
  • I have tried removing `--all` and I still see all commits in addition to the search results (if I can add anything to the search results). – Val Sep 06 '13 at 11:14
  • I don't think you can get it to display just your search results. It treats everything you give it on the command line like a branch head, and shows all history reachable from those commits. – twalberg Sep 06 '13 at 17:34
2

gitk typically can accept all the arguments you might give to git log. So for your case, gitk -S" extremely rare " should show just the commits (plus their immediate parent) that match.

It is equivalent to using the edit view dialog and entering your query into the "Search string" entry field.

patthoyts
  • 32,320
  • 3
  • 62
  • 93
  • The drawback of the gitk GUI search is that you have only one search box there whereas you may enter multiply `-S` options in the command line :) – Val Sep 06 '13 at 16:00
  • Wait, I have checked and gitk -S"text" does not find my text as the search in gitk gui does. I do not understand what does `gitk -Stext` retrieves. – Val Sep 06 '13 at 18:14
  • 1
    The options you pass to gitk really are just forwarded on to git log. It will actually run 'git log --no-color -z --pretty=raw $show_notes --parents --boundary $args "--" $files' where $args contains the command line arguments you provided (eg: -S" rare string "). See line 403 in gitk. – patthoyts Sep 06 '13 at 20:26