Commit 69efd4c49901a7b626009976256a4b3af8de7c4e

Stefan Sperling 2018-07-18T09:57:07

allow entering log view from tree view

diff --git a/tog/tog.1 b/tog/tog.1
index a5af6ac..bb381a1 100644
--- a/tog/tog.1
+++ b/tog/tog.1
@@ -174,6 +174,10 @@ Move the selection cursor up.
 Enter the currently selected directory, or switch to the
 .Cm blame
 view for the currently selected file.
+.It Cm l
+Switch to the
+.Cm log
+view for the currently selected tree entry.
 .It Cm Backspace
 Move back to the parent directory.
 .It Cm i
diff --git a/tog/tog.c b/tog/tog.c
index 44dca03..9906028 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -2122,7 +2122,7 @@ blame_tree_entry(struct got_tree_entry *te, struct tog_parent_trees *parents,
 {
 	const struct got_error *err = NULL;
 	char *path;
-	
+
 	err = tree_entry_path(&path, parents, te);
 	if (err)
 		return err;
@@ -2133,6 +2133,22 @@ blame_tree_entry(struct got_tree_entry *te, struct tog_parent_trees *parents,
 }
 
 static const struct got_error *
+log_tree_entry(struct got_tree_entry *te, struct tog_parent_trees *parents,
+    struct got_object_id *commit_id, struct got_repository *repo)
+{
+	const struct got_error *err = NULL;
+	char *path;
+
+	err = tree_entry_path(&path, parents, te);
+	if (err)
+		return err;
+
+	err = show_log_view(commit_id, repo, path);
+	free(path);
+	return err;
+}
+
+static const struct got_error *
 show_tree_view(struct got_tree_object *root, struct got_object_id *commit_id,
     struct got_repository *repo)
 {
@@ -2202,6 +2218,14 @@ show_tree_view(struct got_tree_object *root, struct got_object_id *commit_id,
 			case 'i':
 				show_ids = !show_ids;
 				break;
+			case 'l':
+				if (selected_entry) {
+					err = log_tree_entry(selected_entry,
+					    &parents, commit_id, repo);
+					if (err)
+						goto done;
+				}
+				break;
 			case 'k':
 			case KEY_UP:
 				if (selected > 0)