index 6e5b0b4b9e131db046d322deacefada5079bb5b4..4216d8700846bc48ba6ca7f95699dd4e0e59b6c3 100644 (file)
--- a/tig.c
+++ b/tig.c
static FILE *opt_tty = NULL;
#define is_initial_commit() (!*opt_head_rev)
+#define is_head_commit(rev) (!strcmp((rev), "HEAD") || !strcmp(opt_head_rev, (rev)))
static enum request
parse_options(int argc, const char *argv[])
}
string_copy(opt_ref, view->vid);
- string_format(opt_file, "%s%s", opt_path, tree_path(line));
return request;
+ case REQ_EDIT:
+ if (line->type != LINE_TREE_FILE) {
+ report("Edit only supported for files");
+ } else if (!is_head_commit(view->vid)) {
+ report("Edit only supported for files in the current work tree");
+ } else {
+ open_editor(TRUE, opt_file);
+ }
+ return REQ_NONE;
+
case REQ_TREE_PARENT:
if (!*opt_path) {
/* quit view if at top of tree */
if (line->type == LINE_TREE_FILE) {
string_copy_rev(ref_blob, text);
+ string_format(opt_file, "%s%s", opt_path, tree_path(line));
} else if (line->type != LINE_TREE_DIR) {
return;