Bound to 'C' by default. Idea by krh on #git.
Set command for retrieving all repository references. The command
should output data in the same format as git-ls-remote(1).
Set command for retrieving all repository references. The command
should output data in the same format as git-ls-remote(1).
+TIG_CHERRY_PICK::
+ Set command for cherry-picking a commit. The command should expect
+ a commit SHA as its final argument.
+
TIG_DIFF_CMD::
The command used for the diff view. By default, git show is used
as a backend.
TIG_DIFF_CMD::
The command used for the diff view. By default, git show is used
as a backend.
REQ_(TOGGLE_LINENO, "Toggle line numbers"), \
REQ_(TOGGLE_REV_GRAPH, "Toggle revision graph visualization"), \
REQ_(STATUS_UPDATE, "Update file status"), \
REQ_(TOGGLE_LINENO, "Toggle line numbers"), \
REQ_(TOGGLE_REV_GRAPH, "Toggle revision graph visualization"), \
REQ_(STATUS_UPDATE, "Update file status"), \
- REQ_(EDIT, "Open in editor")
+ REQ_(EDIT, "Open in editor"), \
+ REQ_(CHERRY_PICK, "Cherry-pick commit to current branch")
/* User action requests. */
/* User action requests. */
{ ':', REQ_PROMPT },
{ 'u', REQ_STATUS_UPDATE },
{ 'e', REQ_EDIT },
{ ':', REQ_PROMPT },
{ 'u', REQ_STATUS_UPDATE },
{ 'e', REQ_EDIT },
+ { 'C', REQ_CHERRY_PICK },
/* Using the ncurses SIGWINCH handler. */
{ KEY_RESIZE, REQ_SCREEN_RESIZE },
/* Using the ncurses SIGWINCH handler. */
{ KEY_RESIZE, REQ_SCREEN_RESIZE },
report("Nothing to edit");
break;
report("Nothing to edit");
break;
+ case REQ_CHERRY_PICK:
+ report("Nothing to cherry-pick");
+ break;
+
case REQ_ENTER:
report("Nothing to enter");
break;
case REQ_ENTER:
report("Nothing to enter");
break;
- case REQ_NONE:
- doupdate();
- return TRUE;
case REQ_VIEW_CLOSE:
/* XXX: Mark closed views by letting view->parent point to the
case REQ_VIEW_CLOSE:
/* XXX: Mark closed views by letting view->parent point to the
+static void
+cherry_pick_commit(struct commit *commit)
+{
+ char cmd[SIZEOF_STR];
+ char *cherry_pick = getenv("TIG_CHERRY_PICK");
+
+ if (!cherry_pick)
+ cherry_pick = "git cherry-pick";
+
+ if (string_format(cmd, "%s %s", cherry_pick, commit->id)) {
+ def_prog_mode(); /* save current tty modes */
+ endwin(); /* restore original tty modes */
+ system(cmd);
+ fprintf(stderr, "Press Enter to continue");
+ getc(stdin);
+ reset_prog_mode();
+ redraw_display();
+ }
+}
+
static enum request
main_request(struct view *view, enum request request, struct line *line)
{
static enum request
main_request(struct view *view, enum request request, struct line *line)
{
if (request == REQ_ENTER)
open_view(view, REQ_VIEW_DIFF, flags);
if (request == REQ_ENTER)
open_view(view, REQ_VIEW_DIFF, flags);
+ else if (request == REQ_CHERRY_PICK)
+ cherry_pick_commit(line->data);
toggle-rev-graph Toggle revision graph visualization
status-update Update file status
edit Open in editor
toggle-rev-graph Toggle revision graph visualization
status-update Update file status
edit Open in editor
+cherry-pick Cherry-pick commit to current branch
------------------------------------------------------------------------------
------------------------------------------------------------------------------