summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 58a5e4e)
raw | patch | inline | side by side (parent: 58a5e4e)
author | Jonas Fonseca <fonseca@diku.dk> | |
Mon, 17 Sep 2007 23:38:42 +0000 (01:38 +0200) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Mon, 17 Sep 2007 23:43:47 +0000 (01:43 +0200) |
Bound to 'C' by default. Idea by krh on #git.
tig.1.txt | patch | blob | history | |
tig.c | patch | blob | history | |
tigrc.5.txt | patch | blob | history |
diff --git a/tig.1.txt b/tig.1.txt
index 13d4059c63eb1ebb27bf8698d1d7a6c7375444cd..efc937b93d31ab53c765dde83140a892e8093a3b 100644 (file)
--- a/tig.1.txt
+++ b/tig.1.txt
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.
index 05ec10c7b407736d111be1e927fe6b182af74f6e..246812f2c6e7fa1518a05a621fe664e95495a600 100644 (file)
--- a/tig.c
+++ b/tig.c
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. */
{ ':', REQ_PROMPT },
{ 'u', REQ_STATUS_UPDATE },
{ 'e', REQ_EDIT },
+ { 'C', REQ_CHERRY_PICK },
/* Using the ncurses SIGWINCH handler. */
{ KEY_RESIZE, REQ_SCREEN_RESIZE },
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_NONE:
- doupdate();
- return TRUE;
case REQ_VIEW_CLOSE:
/* XXX: Mark closed views by letting view->parent point to the
return TRUE;
}
+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)
{
if (request == REQ_ENTER)
open_view(view, REQ_VIEW_DIFF, flags);
+ else if (request == REQ_CHERRY_PICK)
+ cherry_pick_commit(line->data);
else
return request;
diff --git a/tigrc.5.txt b/tigrc.5.txt
index 9d3ad6992f8afc9b2e21780418062e9e312e3121..540de87cc2c7974fa941d608b591f38148c54f2c 100644 (file)
--- a/tigrc.5.txt
+++ b/tigrc.5.txt
toggle-rev-graph Toggle revision graph visualization
status-update Update file status
edit Open in editor
+cherry-pick Cherry-pick commit to current branch
------------------------------------------------------------------------------