RFR: Roll back through old versions of a file in git

A feature I really like in some other editors is the ability to roll through old versions of a file 1 by 1. Trying to consider the best way to do that in Kakoune.

define-command git-edit-force 'edit!; nop %sh(git reset -- "$kak_buffile"); git checkout'
alias global ge! git-edit-force

What I am trying to emulate is Glog from fugitive (http://vimcasts.org/episodes/fugitive-vim-exploring-the-history-of-a-git-repository/).

I think it could be done with connect.kak, by reading the output of a shell command to a buffer (if I understand well the vimcast you linked me).

Example – From a connected terminal:

$ git show 'HEAD~2:src/main.cc' | edit [buffer-name]

Example – From Kakoune:

:connect git show "HEAD~2:%val{buffile}" | edit [buffer-name]

It looks like dark magic, but its function is simple: it reads data from stdin and populates a buffer to a session.

@robertmeta https://github.com/isacikgoz/gitin

I do it with tig interactively:

:connect-terminal tig<ret>

then select desired commit and press t to switch to the tree view. There you can select a file and press e to edit it, or just enter to view.

To show commits of the current buffer only:

:connect-terminal tig <c-r>%<ret>
1 Like

Connect gets more awesome.

You can also try this one:

tig log $(buffer | fzf)

And t for the tree view.

alias gl='tig log $(buffer | fzf)'
alias gL='tig log $(it)'

@vbauerster I recorded a demo using your Tig tips. Very useful.

2 Likes