TIL - Git jump

Posted by Marcus Folkesson on Tuesday, March 14, 2023

TIL - Git jump

TIL, Today I Learned, is more of a "I just figured this out: here are my notes, you may find them useful too" rather than a full blog post

The Git v2.40.0 was released [1] yesterday (2023-03-13) and one of the release notes that caught my eyes was this one:

* "git jump" (in contrib/) learned to present the "quickfix list" to
  its standard output (instead of letting it consumed by the editor
  it invokes), and learned to also drive emacs/emacsclient.

I'm familiar with the "quickfix list" in Vim as I have been using it for many years, I even wrote a small post [2] about it looong time ago.

But what about git jump thing?

What is "quickfix list"

First a few words about quickfix. Quickfix is a list of "interesting" locations in a project such as compilation errors, lint warnings or whatever you want to feed the list with.

Vim has several commands for navigating the quickfix list, here is the most common ones:

  • :copen - Open the quickfix list window.
  • :ccl or :cclose - Close the quickfix list window.
  • :cnext or :cn - Go to the next item on the list.
  • :cprev or :cp - Go to the previous item on the list.
  • :cfirst - Go to the first item on the list.
  • :clast - Go to the last item on the list.

I almost exclusively use the :copen in my daily work. The quickfix list window let you iterate through all items and easily navigate to selected position.

Example on a quickfix window generated with git jump grep compatible:

/media/vim-quickfix.jpg

Git-jump

Git-jump [3] is a contribution script (has it's location in the ./contrib directory of the git repository) and has actually been around since 2011 without me noticing.

Git-jump can help you generate "interesting" quickfix lists and feed it to vim directly. It currently support these lists:

  • The beginning of any diff hunks.

    git jump diff
    
  • The beginning of any merge conflict markers.

    git jump merge
    
  • Any grep matches, including the column of the first match on a line.

    git jump grep compatible
    
  • Any whitespace errors detected by git diff --check.

The script does also supports Emacs, for those who like that kind of thing.

Conclusion

I have only been aware of this tool for a day and it is already totally integrated in my daily workflow.

The commands that I use most are git jump diff and git jump grep. Those are just awesome.