static void main_register_commit(struct view *view, struct commit *commit, const char *ids, bool is_boundary) { struct main_state *state = view->private; string_copy_rev(commit->id, ids); /* FIXME: lazily check index state here instead of in main_open. */ if ((state->add_changes_unstaged || state->add_changes_staged) && is_head_commit(commit->id)) { main_add_changes(view, state, ids); state->add_changes_unstaged = state->add_changes_staged = FALSE; } if (state->with_graph) graph_add_commit(state->graph, &commit->graph, commit->id, ids, is_boundary); }
static enum request tree_request(struct view *view, enum request request, struct line *line) { enum open_flags flags; struct tree_entry *entry = line->data; switch (request) { case REQ_VIEW_BLAME: if (line->type != LINE_FILE) { report("Blame only supported for files"); return REQ_NONE; } string_copy(view->env->ref, view->vid); return request; case REQ_EDIT: if (line->type != LINE_FILE) { report("Edit only supported for files"); } else if (!is_head_commit(view->vid)) { open_blob_editor(entry->id, entry->name, 0); } else { open_editor(view->env->file, 0); } return REQ_NONE; case REQ_PARENT: case REQ_BACK: if (!*view->env->directory) { /* quit view if at top of tree */ return REQ_VIEW_CLOSE; } /* fake 'cd ..' */ pop_tree_stack_entry(&view->pos); reload_view(view); break; case REQ_ENTER: break; default: return request; } /* Cleanup the stack if the tree view is at a different tree. */ if (!*view->env->directory) reset_view_history(&tree_view_history); switch (line->type) { case LINE_DIRECTORY: /* Depending on whether it is a subdirectory or parent link * mangle the path buffer. */ if (tree_path_is_parent(entry->name) && *view->env->directory) { pop_tree_stack_entry(&view->pos); } else { const char *basename = tree_path(line); push_tree_stack_entry(view, basename, &view->pos); } /* Trees and subtrees share the same ID, so they are not not * unique like blobs. */ reload_view(view); break; case LINE_FILE: flags = view_is_displayed(view) ? OPEN_SPLIT : OPEN_DEFAULT; open_blob_view(view, flags); break; default: return REQ_NONE; } return REQ_NONE; }