* tig [options] [--] [git log options]
* tig [options] log [git log options]
* tig [options] diff [git diff options]
* tig [options] [--] [git log options]
* tig [options] log [git log options]
* tig [options] diff [git diff options]
- /**
- * log [options]::
- * git log options.
- *
- * diff [options]::
- * git diff options.
- **/
- if (!strcmp(opt, "log") ||
- !strcmp(opt, "diff")) {
- opt_request = opt[0] == 'l'
- ? REQ_VIEW_LOG : REQ_VIEW_DIFF;
- break;
- }
-
* Optionally, with interval different than each line.
**/
if (!strncmp(opt, "-n", 2) ||
* Optionally, with interval different than each line.
**/
if (!strncmp(opt, "-n", 2) ||
+ /**
+ * log [options]::
+ * Open log view using the given git log options.
+ *
+ * diff [options]::
+ * Open diff view using the given git diff options.
+ *
+ * show [options]::
+ * Open diff view using the given git show options.
+ **/
+ if (!strcmp(opt, "log") ||
+ !strcmp(opt, "diff") ||
+ !strcmp(opt, "show")) {
+ opt_request = opt[0] == 'l'
+ ? REQ_VIEW_LOG : REQ_VIEW_DIFF;
+ break;
+ }
+
+ /* Make stuff like:
if (opt[0] && opt[0] != '-')
break;
die("unknown command '%s'", opt);
}
if (opt[0] && opt[0] != '-')
break;
die("unknown command '%s'", opt);
}
- /**
- * Pager mode
- * ~~~~~~~~~~
- * If stdin is a pipe, any log or diff options will be ignored and the
- * pager view will be opened loading data from stdin. The pager mode
- * can be used for colorizing output from various git commands.
- *
- * Example on how to colorize the output of git-show(1):
- *
- * $ git show | tig
- **/
+ /**
+ * Pager mode
+ * ~~~~~~~~~~
+ * If stdin is a pipe, any log or diff options will be ignored and the
+ * pager view will be opened loading data from stdin. The pager mode
+ * can be used for colorizing output from various git commands.
+ *
+ * Example on how to colorize the output of git-show(1):
+ *
+ * $ git show | tig
+ **/
- /* XXX: This is vulnerable to the user overriding options
- * required for the main view parser. */
+ /**
+ * Git command options
+ * ~~~~~~~~~~~~~~~~~~~
+ *
+ * All git command options specified on the command line will
+ * be passed to the given command and all will be shell quoted
+ * before used.
+ *
+ * NOTE: It is possible to specify options even for the main
+ * view. If doing this you should not touch the --pretty
+ * option.
+ *
+ * Example on how to open the log view and show both author and
+ * committer information:
+ *
+ * $ tig log --pretty=fuller
+ **/
+
string_copy(opt_cmd, "git log --stat --pretty=raw");
else
string_copy(opt_cmd, "git");
string_copy(opt_cmd, "git log --stat --pretty=raw");
else
string_copy(opt_cmd, "git");
* --------- --------------- ---------- ---------- ---------- */ \
/* Diff markup */ \
LINE(DIFF, "diff --git ", COLOR_YELLOW, COLOR_DEFAULT, 0), \
* --------- --------------- ---------- ---------- ---------- */ \
/* Diff markup */ \
LINE(DIFF, "diff --git ", COLOR_YELLOW, COLOR_DEFAULT, 0), \
-LINE(INDEX, "index ", COLOR_BLUE, COLOR_DEFAULT, 0), \
+LINE(DIFF_INDEX, "index ", COLOR_BLUE, COLOR_DEFAULT, 0), \
LINE(DIFF_CHUNK, "@@", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
LINE(DIFF_ADD, "+", COLOR_GREEN, COLOR_DEFAULT, 0), \
LINE(DIFF_DEL, "-", COLOR_RED, COLOR_DEFAULT, 0), \
LINE(DIFF_CHUNK, "@@", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
LINE(DIFF_ADD, "+", COLOR_GREEN, COLOR_DEFAULT, 0), \
LINE(DIFF_DEL, "-", COLOR_RED, COLOR_DEFAULT, 0), \
LINE(DIFF_DISSIM, "dissimilarity ", COLOR_YELLOW, COLOR_DEFAULT, 0), \
/* Pretty print commit header */ \
LINE(PP_AUTHOR, "Author: ", COLOR_CYAN, COLOR_DEFAULT, 0), \
LINE(DIFF_DISSIM, "dissimilarity ", COLOR_YELLOW, COLOR_DEFAULT, 0), \
/* Pretty print commit header */ \
LINE(PP_AUTHOR, "Author: ", COLOR_CYAN, COLOR_DEFAULT, 0), \
LINE(PP_MERGE, "Merge: ", COLOR_BLUE, COLOR_DEFAULT, 0), \
LINE(PP_DATE, "Date: ", COLOR_YELLOW, COLOR_DEFAULT, 0), \
LINE(PP_MERGE, "Merge: ", COLOR_BLUE, COLOR_DEFAULT, 0), \
LINE(PP_DATE, "Date: ", COLOR_YELLOW, COLOR_DEFAULT, 0), \
-LINE(PP_COMMIT, "Commit: ", COLOR_GREEN, COLOR_DEFAULT, 0), \
+LINE(PP_ADATE, "AuthorDate: ", COLOR_YELLOW, COLOR_DEFAULT, 0), \
+LINE(PP_CDATE, "CommitDate: ", COLOR_YELLOW, COLOR_DEFAULT, 0), \
/* Raw commit header */ \
LINE(COMMIT, "commit ", COLOR_GREEN, COLOR_DEFAULT, 0), \
LINE(PARENT, "parent ", COLOR_BLUE, COLOR_DEFAULT, 0), \
LINE(TREE, "tree ", COLOR_BLUE, COLOR_DEFAULT, 0), \
/* Raw commit header */ \
LINE(COMMIT, "commit ", COLOR_GREEN, COLOR_DEFAULT, 0), \
LINE(PARENT, "parent ", COLOR_BLUE, COLOR_DEFAULT, 0), \
LINE(TREE, "tree ", COLOR_BLUE, COLOR_DEFAULT, 0), \
-LINE(AUTHOR_IDENT, "author ", COLOR_CYAN, COLOR_DEFAULT, 0), \
+LINE(AUTHOR, "author ", COLOR_CYAN, COLOR_DEFAULT, 0), \
LINE(COMMITTER, "committer ", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
/* Misc */ \
LINE(DIFF_TREE, "diff-tree ", COLOR_BLUE, COLOR_DEFAULT, 0), \
LINE(COMMITTER, "committer ", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
/* Misc */ \
LINE(DIFF_TREE, "diff-tree ", COLOR_BLUE, COLOR_DEFAULT, 0), \
char ref[SIZEOF_REF]; /* Hovered commit reference */
char vid[SIZEOF_REF]; /* View ID. Set to id member when updating. */
char ref[SIZEOF_REF]; /* Hovered commit reference */
char vid[SIZEOF_REF]; /* View ID. Set to id member when updating. */
{ "diff", DIFF_CMD, ref_commit, sizeof(char), &pager_ops },
{ "log", LOG_CMD, ref_head, sizeof(char), &pager_ops },
{ "help", HELP_CMD, ref_head, sizeof(char), &pager_ops },
{ "diff", DIFF_CMD, ref_commit, sizeof(char), &pager_ops },
{ "log", LOG_CMD, ref_head, sizeof(char), &pager_ops },
{ "help", HELP_CMD, ref_head, sizeof(char), &pager_ops },
- { "pager", "cat", ref_head, sizeof(char), &pager_ops },
+ { "pager", "", "static", sizeof(char), &pager_ops },
} else {
if (snprintf(view->cmd, sizeof(view->cmd), view->cmdfmt,
id, id, id) >= sizeof(view->cmd))
} else {
if (snprintf(view->cmd, sizeof(view->cmd), view->cmdfmt,
id, id, id) >= sizeof(view->cmd))
/* The number of lines to read. If too low it will cause too much
* redrawing (and possible flickering), if too high responsiveness
* will suffer. */
/* The number of lines to read. If too low it will cause too much
* redrawing (and possible flickering), if too high responsiveness
* will suffer. */
string_copy(view->ref, line + 7);
string_copy(ref_commit, view->ref);
string_copy(view->ref, line + 7);
string_copy(ref_commit, view->ref);
- mvwprintw(view->win, lineno, 0, "%4d: ", real_lineno);
- else
- mvwaddstr(view->win, lineno, 0, " : ");
+ mvwprintw(view->win, lineno, 0, "%.*d", view->digits, real_lineno);
+
+ else if (view->digits < sizeof(indent))
+ mvwaddnstr(view->win, lineno, 0, indent, view->digits);
+
+ waddstr(view->win, ": ");
{
char *ident = line + STRING_SIZE("author ");
char *end = strchr(ident, '<');
{
char *ident = line + STRING_SIZE("author ");
char *end = strchr(ident, '<');
} else {
/* Leave stdin and stdout alone when acting as a pager. */
FILE *io = fopen("/dev/tty", "r+");
} else {
/* Leave stdin and stdout alone when acting as a pager. */
FILE *io = fopen("/dev/tty", "r+");
nonl(); /* Tell curses not to do NL->CR/NL on output */
cbreak(); /* Take input chars one at a time, no wait for \n */
noecho(); /* Don't echo input */
nonl(); /* Tell curses not to do NL->CR/NL on output */
cbreak(); /* Take input chars one at a time, no wait for \n */
noecho(); /* Don't echo input */
* - Terminal resizing support. I am yet to figure out whether catching
* SIGWINCH is preferred over using ncurses' built-in support for resizing.
*
* - Terminal resizing support. I am yet to figure out whether catching
* SIGWINCH is preferred over using ncurses' built-in support for resizing.
*