static void blame_go_forward(struct view *view, struct blame *blame, bool parent) { struct blame_state *state = view->private; struct blame_history_state *history_state = &state->history_state; struct blame_commit *commit = blame->commit; const char *id = parent ? commit->parent_id : commit->id; const char *filename = parent ? commit->parent_filename : commit->filename; if (!*id && parent) { report("The selected commit has no parents"); return; } if (!strcmp(history_state->id, id) && !strcmp(history_state->filename, filename)) { report("The selected commit is already displayed"); return; } if (!push_view_history_state(&blame_view_history, &view->pos, history_state)) { report("Failed to save current view state"); return; } string_ncopy(view->env->ref, id, sizeof(commit->id)); string_ncopy(view->env->file, filename, strlen(filename)); if (parent) setup_blame_parent_line(view, blame); view->env->lineno = blame->lineno; reload_view(view); }
static void push_tree_stack_entry(struct view *view, const char *name, struct position *position) { size_t pathlen = strlen(view->env->directory); char *path_position = view->env->directory + pathlen; struct view_state *state = push_view_history_state(&tree_view_history, position, &path_position); if (!state) return; if (!string_format_from(view->env->directory, &pathlen, "%s/", name)) { pop_tree_stack_entry(NULL); return; } clear_position(position); }