Tig: Feature request - default binding to save a patch

Created on 23 Feb 2015  路  3Comments  路  Source: jonas/tig

If tig can show patches, it should let users save them. It's puzzling why such basic functionality doesn't have a default key binding and a documentation entry.

Most helpful comment

This is not a built-in feature, but you can configure a binding to do this. It won't work in all cases since some of the content in the patch (diff) view, for example display of "not yet committed" changes, does not use git show <commitish>.

bind main S ?git format-patch -1 -N %(commit)
bind diff S ?git format-patch -1 -N %(commit)

# Or simply: bind generic S ?git format-patch -1 -N %(commit)

Change the ? to ! to not have Tig prompt you. Change it to @ to not drop into shell-mode and show the output of the command.

All 3 comments

This is not a built-in feature, but you can configure a binding to do this. It won't work in all cases since some of the content in the patch (diff) view, for example display of "not yet committed" changes, does not use git show <commitish>.

bind main S ?git format-patch -1 -N %(commit)
bind diff S ?git format-patch -1 -N %(commit)

# Or simply: bind generic S ?git format-patch -1 -N %(commit)

Change the ? to ! to not have Tig prompt you. Change it to @ to not drop into shell-mode and show the output of the command.

My .tigrc had the line with main, but generic is better. Thank you!

But my point was that the save feature is so basic that it should be enabled by default and documented. Maybe in some more sophisticated form, with staged and unstaged support and without Press Enter to continue. The patch name should probably start with tig rather than with the pointless 0001.

Hi, I'm using an old system which the specific version of libreadline required by tig is not available, so completion and history in search and command prompts are not usable.

OK, this is not the point, the point is, saving the context of the buffer such as diff buffer or any content of the current view is really useful, especially for such situation, then I can open the saved file using editor like vim without using tig to reload it everytime and may use the search feature in vim.

I already know how to save a committed diff to a local file such as using
~
bind diff gS !>sh -c "git show %(commit) > %(commit).diff"
~

but this is not working for staged/uncommitted diff buffer like you said since there is no %(commit).

So I'm wondering if there is any thing like %(buffer) for us to use, the %(buffer) is the whole content of the current view, such as main view, stage view, diff view.

Currently I'm using
~
bind stage gS !>sh -c "git diff HEAD > stage.diff"
~

to save the stage buffer, but there are three stats in stage view: staged, unstaged, untracked,
the git diff HEAD doesn't cover them all and may output more result than what I need sometimes, so the %(buffer) I mentioned is more accurate.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seiyeah78 picture seiyeah78  路  7Comments

elbenfreund picture elbenfreund  路  7Comments

dmalikov picture dmalikov  路  4Comments

achikin picture achikin  路  7Comments

Anrock picture Anrock  路  8Comments