index c8ab944dd804192c6f37344fc24d4f19726d7d05..a31d18eb23bd1213610bc94fe78f09e2836bff8d 100644 (file)
--- a/tig.c
+++ b/tig.c
enum format_flags {
FORMAT_ALL, /* Perform replacement in all arguments. */
enum format_flags {
FORMAT_ALL, /* Perform replacement in all arguments. */
- FORMAT_DASH, /* Perform replacement up until "--". */
FORMAT_NONE /* No replacement should be performed. */
};
FORMAT_NONE /* No replacement should be performed. */
};
@@ -520,6 +519,7 @@ utf8_length(const char **start, size_t skip, int *width, size_t max_width, int *
#define DATE_INFO \
DATE_(NO), \
DATE_(DEFAULT), \
#define DATE_INFO \
DATE_(NO), \
DATE_(DEFAULT), \
+ DATE_(LOCAL), \
DATE_(RELATIVE), \
DATE_(SHORT)
DATE_(RELATIVE), \
DATE_(SHORT)
}
}
}
}
- gmtime_r(&time->sec, &tm);
+ if (date == DATE_LOCAL) {
+ time_t date = time->sec + time->tz;
+ localtime_r(&date, &tm);
+ }
+ else {
+ gmtime_r(&time->sec, &tm);
+ }
return strftime(buf, sizeof(buf), DATE_FORMAT, &tm) ? buf : NULL;
}
return strftime(buf, sizeof(buf), DATE_FORMAT, &tm) ? buf : NULL;
}
#define REQ_(req, help) REQ_##req
/* Offset all requests to avoid conflicts with ncurses getch values. */
#define REQ_(req, help) REQ_##req
/* Offset all requests to avoid conflicts with ncurses getch values. */
- REQ_OFFSET = KEY_MAX + 1,
+ REQ_UNKNOWN = KEY_MAX + 1,
+ REQ_OFFSET,
REQ_INFO
#undef REQ_GROUP
REQ_INFO
#undef REQ_GROUP
if (enum_equals(req_info[i], name, namelen))
return req_info[i].request;
if (enum_equals(req_info[i], name, namelen))
return req_info[i].request;
- return REQ_NONE;
+ return REQ_UNKNOWN;
}
}
LINE(COMMITTER, "committer ", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
LINE(SIGNOFF, " Signed-off-by", COLOR_YELLOW, COLOR_DEFAULT, 0), \
LINE(ACKED, " Acked-by", COLOR_YELLOW, COLOR_DEFAULT, 0), \
LINE(COMMITTER, "committer ", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
LINE(SIGNOFF, " Signed-off-by", COLOR_YELLOW, COLOR_DEFAULT, 0), \
LINE(ACKED, " Acked-by", COLOR_YELLOW, COLOR_DEFAULT, 0), \
+LINE(TESTED, " Tested-by", COLOR_YELLOW, COLOR_DEFAULT, 0), \
+LINE(REVIEWED, " Reviewed-by", COLOR_YELLOW, COLOR_DEFAULT, 0), \
LINE(DEFAULT, "", COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL), \
LINE(CURSOR, "", COLOR_WHITE, COLOR_GREEN, A_BOLD), \
LINE(STATUS, "", COLOR_GREEN, COLOR_DEFAULT, 0), \
LINE(DEFAULT, "", COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL), \
LINE(CURSOR, "", COLOR_WHITE, COLOR_GREEN, A_BOLD), \
LINE(STATUS, "", COLOR_GREEN, COLOR_DEFAULT, 0), \
enum request request;
};
enum request request;
};
-static const struct keybinding default_keybindings[] = {
+static struct keybinding default_keybindings[] = {
/* View switching */
{ 'm', REQ_VIEW_MAIN },
{ 'd', REQ_VIEW_DIFF },
/* View switching */
{ 'm', REQ_VIEW_MAIN },
{ 'd', REQ_VIEW_DIFF },
add_keybinding(enum keymap keymap, enum request request, int key)
{
struct keybinding_table *table = &keybindings[keymap];
add_keybinding(enum keymap keymap, enum request request, int key)
{
struct keybinding_table *table = &keybindings[keymap];
+ size_t i;
+
+ for (i = 0; i < keybindings[keymap].size; i++) {
+ if (keybindings[keymap].data[i].alias == key) {
+ keybindings[keymap].data[i].request = request;
+ return;
+ }
+ }
table->data = realloc(table->data, (table->size + 1) * sizeof(*table->data));
if (!table->data)
die("Failed to allocate keybinding");
table->data[table->size].alias = key;
table->data[table->size++].request = request;
table->data = realloc(table->data, (table->size + 1) * sizeof(*table->data));
if (!table->data)
die("Failed to allocate keybinding");
table->data[table->size].alias = key;
table->data[table->size++].request = request;
+
+ if (request == REQ_NONE && keymap == KEYMAP_GENERIC) {
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(default_keybindings); i++)
+ if (default_keybindings[i].alias == key)
+ default_keybindings[i].request = REQ_NONE;
+ }
}
/* Looks for a key binding first in the given map, then in the generic map, and
}
/* Looks for a key binding first in the given map, then in the generic map, and
int i;
for (i = 0; i < ARRAY_SIZE(reqs); i++) {
int i;
for (i = 0; i < ARRAY_SIZE(reqs); i++) {
- enum request req;
+ enum request req = get_keybinding(reqs[i].keymap, reqs[i].key);
+ if (req != reqs[i].key)
+ continue;
req = add_run_request(reqs[i].keymap, reqs[i].key, reqs[i].argc, reqs[i].argv);
if (req != REQ_NONE)
add_keybinding(reqs[i].keymap, req, reqs[i].key);
req = add_run_request(reqs[i].keymap, reqs[i].key, reqs[i].argc, reqs[i].argv);
if (req != REQ_NONE)
add_keybinding(reqs[i].keymap, req, reqs[i].key);
return ERR;
}
return ERR;
}
- if (set_keymap(&keymap, argv[0]) == ERR) {
+ if (!set_keymap(&keymap, argv[0])) {
config_msg = "Unknown key map";
return ERR;
}
config_msg = "Unknown key map";
return ERR;
}
}
request = get_request(argv[2]);
}
request = get_request(argv[2]);
- if (request == REQ_NONE) {
+ if (request == REQ_UNKNOWN) {
static const struct enum_map obsolete[] = {
ENUM_MAP("cherry-pick", REQ_NONE),
ENUM_MAP("screen-resize", REQ_NONE),
static const struct enum_map obsolete[] = {
ENUM_MAP("cherry-pick", REQ_NONE),
ENUM_MAP("screen-resize", REQ_NONE),
return ERR;
}
}
return ERR;
}
}
- if (request == REQ_NONE && *argv[2]++ == '!')
+ if (request == REQ_UNKNOWN && *argv[2]++ == '!')
request = add_run_request(keymap, key, argc - 2, argv + 2);
request = add_run_request(keymap, key, argc - 2, argv + 2);
- if (request == REQ_NONE) {
+ if (request == REQ_UNKNOWN) {
config_msg = "Unknown request name";
return ERR;
}
config_msg = "Unknown request name";
return ERR;
}
const char *tigrc_system = getenv("TIGRC_SYSTEM");
char buf[SIZEOF_STR];
const char *tigrc_system = getenv("TIGRC_SYSTEM");
char buf[SIZEOF_STR];
- add_builtin_run_requests();
-
if (!tigrc_system)
tigrc_system = SYSCONFDIR "/tigrc";
load_option_file(tigrc_system);
if (!tigrc_system)
tigrc_system = SYSCONFDIR "/tigrc";
load_option_file(tigrc_system);
}
load_option_file(tigrc_user);
}
load_option_file(tigrc_user);
+ /* Add _after_ loading config files to avoid adding run requests
+ * that conflict with keybindings. */
+ add_builtin_run_requests();
+
return OK;
}
return OK;
}
static char ref_head[SIZEOF_REF] = "HEAD";
static char ref_branch[SIZEOF_REF] = "";
static char ref_head[SIZEOF_REF] = "HEAD";
static char ref_branch[SIZEOF_REF] = "";
+enum view_type {
+ VIEW_MAIN,
+ VIEW_DIFF,
+ VIEW_LOG,
+ VIEW_TREE,
+ VIEW_BLOB,
+ VIEW_BLAME,
+ VIEW_BRANCH,
+ VIEW_HELP,
+ VIEW_PAGER,
+ VIEW_STATUS,
+ VIEW_STAGE,
+};
+
struct view {
struct view {
+ enum view_type type; /* View type */
const char *name; /* View name */
const char *cmd_env; /* Command line set via environment */
const char *id; /* Points to either of ref_{head,commit,blob} */
const char *name; /* View name */
const char *cmd_env; /* Command line set via environment */
const char *id; /* Points to either of ref_{head,commit,blob} */
enum keymap keymap; /* What keymap does this view have */
bool git_dir; /* Whether the view requires a git directory. */
enum keymap keymap; /* What keymap does this view have */
bool git_dir; /* Whether the view requires a git directory. */
+ bool refresh; /* Whether the view supports refreshing. */
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. */
/* If non-NULL, points to the view that opened this view. If this view
* is closed tig will switch back to the parent view. */
struct view *parent;
/* If non-NULL, points to the view that opened this view. If this view
* is closed tig will switch back to the parent view. */
struct view *parent;
+ struct view *prev;
/* Buffering */
size_t lines; /* Total number of lines */
/* Buffering */
size_t lines; /* Total number of lines */
static struct view_ops tree_ops;
static struct view_ops branch_ops;
static struct view_ops tree_ops;
static struct view_ops branch_ops;
-#define VIEW_STR(name, env, ref, ops, map, git) \
- { name, #env, ref, ops, map, git }
-
-#define VIEW_(id, name, ops, git, ref) \
- VIEW_STR(name, TIG_##id##_CMD, ref, ops, KEYMAP_##id, git)
+#define VIEW_STR(type, name, env, ref, ops, map, git, refresh) \
+ { type, name, #env, ref, ops, map, git, refresh }
+#define VIEW_(id, name, ops, git, refresh, ref) \
+ VIEW_STR(VIEW_##id, name, TIG_##id##_CMD, ref, ops, KEYMAP_##id, git, refresh)
static struct view views[] = {
static struct view views[] = {
- VIEW_(MAIN, "main", &main_ops, TRUE, ref_head),
- VIEW_(DIFF, "diff", &diff_ops, TRUE, ref_commit),
- VIEW_(LOG, "log", &log_ops, TRUE, ref_head),
- VIEW_(TREE, "tree", &tree_ops, TRUE, ref_commit),
- VIEW_(BLOB, "blob", &blob_ops, TRUE, ref_blob),
- VIEW_(BLAME, "blame", &blame_ops, TRUE, ref_commit),
- VIEW_(BRANCH, "branch", &branch_ops, TRUE, ref_head),
- VIEW_(HELP, "help", &help_ops, FALSE, ""),
- VIEW_(PAGER, "pager", &pager_ops, FALSE, "stdin"),
- VIEW_(STATUS, "status", &status_ops, TRUE, ""),
- VIEW_(STAGE, "stage", &stage_ops, TRUE, ""),
+ VIEW_(MAIN, "main", &main_ops, TRUE, TRUE, ref_head),
+ VIEW_(DIFF, "diff", &diff_ops, TRUE, FALSE, ref_commit),
+ VIEW_(LOG, "log", &log_ops, TRUE, TRUE, ref_head),
+ VIEW_(TREE, "tree", &tree_ops, TRUE, FALSE, ref_commit),
+ VIEW_(BLOB, "blob", &blob_ops, TRUE, FALSE, ref_blob),
+ VIEW_(BLAME, "blame", &blame_ops, TRUE, FALSE, ref_commit),
+ VIEW_(BRANCH, "branch", &branch_ops, TRUE, TRUE, ref_head),
+ VIEW_(HELP, "help", &help_ops, FALSE, FALSE, ""),
+ VIEW_(PAGER, "pager", &pager_ops, FALSE, FALSE, "stdin"),
+ VIEW_(STATUS, "status", &status_ops, TRUE, TRUE, ""),
+ VIEW_(STAGE, "stage", &stage_ops, TRUE, TRUE, ""),
};
#define VIEW(req) (&views[(req) - REQ_OFFSET - 1])
};
#define VIEW(req) (&views[(req) - REQ_OFFSET - 1])
-#define VIEW_REQ(view) ((view) - views + REQ_OFFSET + 1)
#define foreach_view(view, i) \
for (i = 0; i < ARRAY_SIZE(views) && (view = &views[i]); i++)
#define foreach_view(view, i) \
for (i = 0; i < ARRAY_SIZE(views) && (view = &views[i]); i++)
(view == display[0] || view == display[1])
(view == display[0] || view == display[1])
+/*
+ * View drawing.
+ */
+
static inline void
set_view_attr(struct view *view, enum line_type type)
{
static inline void
set_view_attr(struct view *view, enum line_type type)
{
assert(view_is_displayed(view));
assert(view_is_displayed(view));
- if (view != VIEW(REQ_VIEW_STATUS) && view->lines) {
+ if (view->type != VIEW_STATUS && view->lines) {
unsigned int view_lines = view->offset + view->height;
unsigned int lines = view->lines
? MIN(view_lines, view->lines) * 100 / view->lines
unsigned int view_lines = view->offset + view->height;
unsigned int lines = view->lines
? MIN(view_lines, view->lines) * 100 / view->lines
}
}
}
}
+
+/*
+ * Option management
+ */
+
static void
toggle_enum_option_do(unsigned int *opt, const char *help,
const struct enum_map *map, size_t size)
static void
toggle_enum_option_do(unsigned int *opt, const char *help,
const struct enum_map *map, size_t size)
@@ -3146,8 +3199,6 @@ format_argv(const char *dst_argv[], const char *src_argv[], enum format_flags fl
const char *value;
if (!next || noreplace) {
const char *value;
if (!next || noreplace) {
- if (flags == FORMAT_DASH && !strcmp(arg, "--"))
- noreplace = TRUE;
len = strlen(arg);
value = "";
len = strlen(arg);
value = "";
}
static bool
}
static bool
-prepare_update(struct view *view, const char *argv[], const char *dir,
- enum format_flags flags)
+prepare_update(struct view *view, const char *argv[], const char *dir)
{
if (view->pipe)
end_update(view, TRUE);
{
if (view->pipe)
end_update(view, TRUE);
- return io_format(&view->io, dir, IO_RD, argv, flags);
+ return io_format(&view->io, dir, IO_RD, argv, FORMAT_NONE);
}
static bool
}
static bool
/* Keep the displayed view in sync with line number scaling. */
if (digits != view->digits) {
view->digits = digits;
/* Keep the displayed view in sync with line number scaling. */
if (digits != view->digits) {
view->digits = digits;
- if (opt_line_number || view == VIEW(REQ_VIEW_BLAME))
+ if (opt_line_number || view->type == VIEW_BLAME)
redraw = TRUE;
}
}
redraw = TRUE;
}
}
end_update(view, TRUE);
} else if (io_eof(view->pipe)) {
end_update(view, TRUE);
} else if (io_eof(view->pipe)) {
- report("");
+ if (view_is_displayed(view))
+ report("");
end_update(view, FALSE);
}
end_update(view, FALSE);
}
if (split) {
display[1] = view;
current_view = 1;
if (split) {
display[1] = view;
current_view = 1;
+ view->parent = prev;
} else if (!nomaximize) {
/* Maximize the current view. */
memset(display, 0, sizeof(display));
} else if (!nomaximize) {
/* Maximize the current view. */
memset(display, 0, sizeof(display));
display[current_view] = view;
}
display[current_view] = view;
}
- /* No parent signals that this is the first loaded view. */
+ /* No prev signals that this is the first loaded view. */
if (prev && view != prev) {
if (prev && view != prev) {
- view->parent = prev;
+ view->prev = prev;
}
/* Resize the view when switching between split- and full-screen,
}
/* Resize the view when switching between split- and full-screen,
if (request > REQ_NONE) {
open_run_request(request);
/* FIXME: When all views can refresh always do this. */
if (request > REQ_NONE) {
open_run_request(request);
/* FIXME: When all views can refresh always do this. */
- if (view == VIEW(REQ_VIEW_STATUS) ||
- view == VIEW(REQ_VIEW_MAIN) ||
- view == VIEW(REQ_VIEW_LOG) ||
- view == VIEW(REQ_VIEW_BRANCH) ||
- view == VIEW(REQ_VIEW_STAGE))
+ if (view->refresh)
request = REQ_REFRESH;
else
return TRUE;
request = REQ_REFRESH;
else
return TRUE;
case REQ_PREVIOUS:
request = request == REQ_NEXT ? REQ_MOVE_DOWN : REQ_MOVE_UP;
case REQ_PREVIOUS:
request = request == REQ_NEXT ? REQ_MOVE_DOWN : REQ_MOVE_UP;
- if ((view == VIEW(REQ_VIEW_DIFF) &&
- view->parent == VIEW(REQ_VIEW_MAIN)) ||
- (view == VIEW(REQ_VIEW_DIFF) &&
- view->parent == VIEW(REQ_VIEW_BLAME)) ||
- (view == VIEW(REQ_VIEW_STAGE) &&
- view->parent == VIEW(REQ_VIEW_STATUS)) ||
- (view == VIEW(REQ_VIEW_BLOB) &&
- view->parent == VIEW(REQ_VIEW_TREE)) ||
- (view == VIEW(REQ_VIEW_MAIN) &&
- view->parent == VIEW(REQ_VIEW_BRANCH))) {
+ if (view->parent) {
int line;
view = view->parent;
int line;
view = view->parent;
break;
case REQ_STOP_LOADING:
break;
case REQ_STOP_LOADING:
- for (i = 0; i < ARRAY_SIZE(views); i++) {
- view = &views[i];
+ foreach_view(view, i) {
if (view->pipe)
report("Stopped loading the %s view", view->name),
end_update(view, TRUE);
if (view->pipe)
report("Stopped loading the %s view", view->name),
end_update(view, TRUE);
break;
case REQ_VIEW_CLOSE:
break;
case REQ_VIEW_CLOSE:
- /* XXX: Mark closed views by letting view->parent point to the
+ /* XXX: Mark closed views by letting view->prev point to the
* view itself. Parents to closed view should never be
* followed. */
* view itself. Parents to closed view should never be
* followed. */
- if (view->parent &&
- view->parent->parent != view->parent) {
- maximize_view(view->parent);
- view->parent = view;
+ if (view->prev && view->prev != view) {
+ maximize_view(view->prev);
+ view->prev = view;
break;
}
/* Fall-through */
break;
}
/* Fall-through */
tz = ('0' - zone[1]) * 60 * 60 * 10;
tz += ('0' - zone[2]) * 60 * 60;
tz = ('0' - zone[1]) * 60 * 60 * 10;
tz += ('0' - zone[2]) * 60 * 60;
- tz += ('0' - zone[3]) * 60;
- tz += ('0' - zone[4]);
+ tz += ('0' - zone[3]) * 60 * 10;
+ tz += ('0' - zone[4]) * 60;
if (zone[0] == '-')
tz = -tz;
if (zone[0] == '-')
tz = -tz;
return FALSE;
}
return FALSE;
}
- if (parents > 1 && !open_commit_parent_menu(buf, &parents))
+ if (parents == 1)
+ parents = 0;
+ else if (!open_commit_parent_menu(buf, &parents))
return FALSE;
string_copy_rev(rev, &buf[41 * parents]);
return FALSE;
string_copy_rev(rev, &buf[41 * parents]);
list = get_ref_list(commit_id);
if (!list) {
list = get_ref_list(commit_id);
if (!list) {
- if (view == VIEW(REQ_VIEW_DIFF))
+ if (view->type == VIEW_DIFF)
goto try_add_describe_ref;
return;
}
goto try_add_describe_ref;
return;
}
is_tag = TRUE;
}
is_tag = TRUE;
}
- if (!is_tag && view == VIEW(REQ_VIEW_DIFF)) {
+ if (!is_tag && view->type == VIEW_DIFF) {
try_add_describe_ref:
/* Add <tag>-g<commit_id> "fake" reference. */
if (!add_describe_ref(buf, &bufpos, commit_id, sep))
try_add_describe_ref:
/* Add <tag>-g<commit_id> "fake" reference. */
if (!add_describe_ref(buf, &bufpos, commit_id, sep))
return FALSE;
if (line->type == LINE_COMMIT &&
return FALSE;
if (line->type == LINE_COMMIT &&
- (view == VIEW(REQ_VIEW_DIFF) ||
- view == VIEW(REQ_VIEW_LOG)))
+ (view->type == VIEW_DIFF ||
+ view->type == VIEW_LOG))
add_pager_refs(view, line);
return TRUE;
add_pager_refs(view, line);
return TRUE;
return request;
if (line->type == LINE_COMMIT &&
return request;
if (line->type == LINE_COMMIT &&
- (view == VIEW(REQ_VIEW_LOG) ||
- view == VIEW(REQ_VIEW_PAGER))) {
+ (view->type == VIEW_LOG ||
+ view->type == VIEW_PAGER)) {
open_view(view, REQ_VIEW_DIFF, OPEN_SPLIT);
split = 1;
}
open_view(view, REQ_VIEW_DIFF, OPEN_SPLIT);
split = 1;
}
if (line->type == LINE_COMMIT) {
char *text = (char *)line->data + STRING_SIZE("commit ");
if (line->type == LINE_COMMIT) {
char *text = (char *)line->data + STRING_SIZE("commit ");
- if (view != VIEW(REQ_VIEW_PAGER))
+ if (view->type != VIEW_PAGER)
string_copy_rev(view->ref, text);
string_copy_rev(ref_commit, text);
}
string_copy_rev(view->ref, text);
string_copy_rev(ref_commit, text);
}
break;
case LINE_TREE_FILE:
break;
case LINE_TREE_FILE:
- flags = display[0] == view ? OPEN_SPLIT : OPEN_DEFAULT;
+ flags = view_is_displayed(view) ? OPEN_SPLIT : OPEN_DEFAULT;
request = REQ_VIEW_BLOB;
break;
request = REQ_VIEW_BLOB;
break;
{
char path[SIZEOF_STR];
{
char path[SIZEOF_STR];
- if (!view->parent && *opt_prefix) {
+ if (!view->prev && *opt_prefix) {
string_copy(path, opt_file);
if (!string_format(opt_file, "%s%s", opt_prefix, path))
return FALSE;
string_copy(path, opt_file);
if (!string_format(opt_file, "%s%s", opt_prefix, path))
return FALSE;
const char **argv = *opt_ref ? blame_ref_argv : blame_head_argv;
struct io io = {};
const char **argv = *opt_ref ? blame_ref_argv : blame_head_argv;
struct io io = {};
- if (view->lines == 0 && !view->parent)
+ if (view->lines == 0 && !view->prev)
die("No blame exist for %s", view->vid);
if (view->lines == 0 || !io_run_rd(&io, argv, opt_cdup, FORMAT_ALL)) {
die("No blame exist for %s", view->vid);
if (view->lines == 0 || !io_run_rd(&io, argv, opt_cdup, FORMAT_ALL)) {
static enum request
blame_request(struct view *view, enum request request, struct line *line)
{
static enum request
blame_request(struct view *view, enum request request, struct line *line)
{
- enum open_flags flags = display[0] == view ? OPEN_SPLIT : OPEN_DEFAULT;
+ enum open_flags flags = view_is_displayed(view) ? OPEN_SPLIT : OPEN_DEFAULT;
struct blame *blame = line->data;
switch (request) {
struct blame *blame = line->data;
switch (request) {
diff_index_argv[7] = "/dev/null";
}
diff_index_argv[7] = "/dev/null";
}
- if (!prepare_update(diff, diff_index_argv, NULL, FORMAT_DASH)) {
+ if (!prepare_update(diff, diff_index_argv, NULL)) {
report("Failed to allocate diff command");
break;
}
report("Failed to allocate diff command");
break;
}
};
struct view *main_view = VIEW(REQ_VIEW_MAIN);
};
struct view *main_view = VIEW(REQ_VIEW_MAIN);
- if (!prepare_update(main_view, all_branches_argv, NULL, FORMAT_NONE)) {
+ if (!prepare_update(main_view, all_branches_argv, NULL)) {
report("Failed to load view of all branches");
return REQ_NONE;
}
report("Failed to load view of all branches");
return REQ_NONE;
}
"--", "/dev/null", newpath, NULL
};
"--", "/dev/null", newpath, NULL
};
- if (!prepare_update(stage, no_head_diff_argv, opt_cdup, FORMAT_DASH))
+ if (!prepare_update(stage, no_head_diff_argv, opt_cdup))
return status_load_error(view, stage, newpath);
} else {
const char *index_show_argv[] = {
return status_load_error(view, stage, newpath);
} else {
const char *index_show_argv[] = {
oldpath, newpath, NULL
};
oldpath, newpath, NULL
};
- if (!prepare_update(stage, index_show_argv, opt_cdup, FORMAT_DASH))
+ if (!prepare_update(stage, index_show_argv, opt_cdup))
return status_load_error(view, stage, newpath);
}
return status_load_error(view, stage, newpath);
}
"-C", "-M", "--", oldpath, newpath, NULL
};
"-C", "-M", "--", oldpath, newpath, NULL
};
- if (!prepare_update(stage, files_show_argv, opt_cdup, FORMAT_DASH))
+ if (!prepare_update(stage, files_show_argv, opt_cdup))
return status_load_error(view, stage, newpath);
if (status)
info = "Unstaged changes to %s";
return status_load_error(view, stage, newpath);
if (status)
info = "Unstaged changes to %s";
die("line type %d not handled in switch", line->type);
}
die("line type %d not handled in switch", line->type);
}
- split = view_is_displayed(view) ? OPEN_SPLIT : 0;
+ split = view_is_displayed(view) ? OPEN_SPLIT : OPEN_DEFAULT;
open_view(view, REQ_VIEW_STAGE, OPEN_PREPARED | split);
if (view_is_displayed(VIEW(REQ_VIEW_STAGE))) {
if (status) {
open_view(view, REQ_VIEW_STAGE, OPEN_PREPARED | split);
if (view_is_displayed(VIEW(REQ_VIEW_STAGE))) {
if (status) {
if (!line) {
int i;
if (!line) {
int i;
- if (!view->lines && !view->parent)
+ if (!view->lines && !view->prev)
die("No revisions match the given arguments.");
if (view->lines > 0) {
commit = view->line[view->lines - 1].data;
die("No revisions match the given arguments.");
if (view->lines > 0) {
commit = view->line[view->lines - 1].data;
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)
{
- enum open_flags flags = display[0] == view ? OPEN_SPLIT : OPEN_DEFAULT;
+ enum open_flags flags = view_is_displayed(view) ? OPEN_SPLIT : OPEN_DEFAULT;
switch (request) {
case REQ_ENTER:
switch (request) {
case REQ_ENTER:
die("command too long");
}
die("command too long");
}
- if (!prepare_update(VIEW(request), custom_argv, NULL, FORMAT_NONE))
+ if (!prepare_update(VIEW(request), custom_argv, NULL))
die("Failed to format arguments");
return request;
die("Failed to format arguments");
return request;
/* Some low-level request handling. This keeps access to
* status_win restricted. */
switch (request) {
/* Some low-level request handling. This keeps access to
* status_win restricted. */
switch (request) {
+ case REQ_NONE:
+ report("Unknown key, press %s for help",
+ get_key(view->keymap, REQ_VIEW_HELP));
+ break;
case REQ_PROMPT:
{
char *cmd = read_prompt(":");
case REQ_PROMPT:
{
char *cmd = read_prompt(":");
if (!argv_from_string(argv, &argc, cmd)) {
report("Too many arguments");
if (!argv_from_string(argv, &argc, cmd)) {
report("Too many arguments");
- } else if (!prepare_update(next, argv, NULL, FORMAT_DASH)) {
+ } else if (!prepare_update(next, argv, NULL)) {
report("Failed to format command");
} else {
open_view(view, REQ_VIEW_PAGER, OPEN_PREPARED);
report("Failed to format command");
} else {
open_view(view, REQ_VIEW_PAGER, OPEN_PREPARED);