summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9eb14b7)
raw | patch | inline | side by side (parent: 9eb14b7)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sat, 6 Oct 2007 22:32:54 +0000 (00:32 +0200) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Sat, 6 Oct 2007 22:56:50 +0000 (00:56 +0200) |
manual.txt | patch | blob | history | |
tig.1.txt | patch | blob | history | |
tig.c | patch | blob | history | |
tigrc.5.txt | patch | blob | history |
diff --git a/manual.txt b/manual.txt
index b976ece2a095faf39e60eb2536529b2a5d3474ce..372391ecf44adbbb9e9dcc448407269982e62d00 100644 (file)
--- a/manual.txt
+++ b/manual.txt
preferred merge tool. See the manpage of git-mergetool(1).
-----------------------------------------------------------------------------
+[[external-commands]]
+External Commands
+~~~~~~~~~~~~~~~~~
+
+Tig also comes with a few builtin external commands. These are simple shell
+commands that are run and can take arguments from the current browsing state,
+such as the current commit ID. The default commands are:
+
+`-------`--------------------------------------------------------------------
+Key Action
+-----------------------------------------------------------------------------
+C git cherry-pick %(commit)
+G git gc
+-----------------------------------------------------------------------------
+
[[refspec]]
Revision Specification
----------------------
diff --git a/tig.1.txt b/tig.1.txt
index efc937b93d31ab53c765dde83140a892e8093a3b..13d4059c63eb1ebb27bf8698d1d7a6c7375444cd 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 84e51b0733bf9e81766e449faafebf0bed068657..5fb529ec69b5d96f2ab781c4d7bba2bdcaa574aa 100644 (file)
--- a/tig.c
+++ b/tig.c
REQ_(STATUS_UPDATE, "Update file status"), \
REQ_(STATUS_MERGE, "Merge file using external tool"), \
REQ_(EDIT, "Open in editor"), \
- REQ_(CHERRY_PICK, "Cherry-pick commit to current branch"), \
REQ_(NONE, "Do nothing")
{ 'u', REQ_STATUS_UPDATE },
{ 'M', REQ_STATUS_MERGE },
{ 'e', REQ_EDIT },
- { 'C', REQ_CHERRY_PICK },
/* Using the ncurses SIGWINCH handler. */
{ KEY_RESIZE, REQ_SCREEN_RESIZE },
return &run_request[request - REQ_NONE - 1];
}
+static void
+add_builtin_run_requests(void)
+{
+ struct {
+ enum keymap keymap;
+ int key;
+ char *argv[1];
+ } reqs[] = {
+ { KEYMAP_MAIN, 'C', { "git cherry-pick %(commit)" } },
+ { KEYMAP_GENERIC, 'G', { "git gc" } },
+ };
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(reqs); i++) {
+ enum request req;
+
+ req = add_run_request(reqs[i].keymap, reqs[i].key, 1, reqs[i].argv);
+ if (req != REQ_NONE)
+ add_keybinding(reqs[i].keymap, req, reqs[i].key);
+ }
+}
+
/*
* User config file handling.
*/
}
request = get_request(argv[2]);
+ if (request = REQ_NONE) {
+ const char *obsolete[] = { "cherry-pick" };
+ size_t namelen = strlen(argv[2]);
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(obsolete); i++) {
+ if (namelen == strlen(obsolete[i]) &&
+ !string_enum_compare(obsolete[i], argv[2], namelen)) {
+ config_msg = "Obsolete request name";
+ return ERR;
+ }
+ }
+ }
if (request == REQ_NONE && *argv[2]++ == '!')
request = add_run_request(keymap, key, argc - 2, argv + 2);
if (request == REQ_NONE) {
config_lineno = 0;
config_errors = FALSE;
+ add_builtin_run_requests();
+
if (!home || !string_format(buf, "%s/.tigrc", home))
return ERR;
report("Nothing to edit");
break;
- case REQ_CHERRY_PICK:
- report("Nothing to cherry-pick");
- break;
case REQ_ENTER:
report("Nothing to enter");
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)) {
- open_external_viewer(cmd);
- }
-}
-
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 bfb122396b29ea2a3d9a2086ac3daf3d05d52bf2..55e34a5cec0aeedfb8a88cddba12dada29fb40ff 100644 (file)
--- a/tigrc.5.txt
+++ b/tigrc.5.txt
status-update Update file status
status-merge Resolve unmerged file
edit Open in editor
-cherry-pick Cherry-pick commit to current branch
------------------------------------------------------------------------------