allow entering log view from tree view
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
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)