Commit Diff


commit - 7837eeac2ff69333430c0e0adb259d6c2b6a69ed
commit + 5036bf3733fae65f40cdc01cc2150ec88fdc7321
blob - 91f55cbb6f1a4a9895d4eef1a1a213d9cc0fafe4
blob + 4e27b78201cce05e08b450d12b79f02f312b3cbf
--- tog/tog.1
+++ tog/tog.1
@@ -106,6 +106,8 @@ updated when the other switches to a different commit.
 Switch to the
 .Cm tree
 view showing the tree for the currently selected commit.
+.It Cm Backspace
+Show log entries for the parent directory of the currently selected path.
 .El
 .Pp
 The options for
blob - 2c93b3c542093bcb6cd991a9b688df076de12603
blob + 78fbabbe780325781f33ac15d82be15a129bc8d0
--- tog/tog.c
+++ tog/tog.c
@@ -34,6 +34,7 @@
 #include <wchar.h>
 #include <time.h>
 #include <pthread.h>
+#include <libgen.h>
 
 #include "got_error.h"
 #include "got_object.h"
@@ -117,6 +118,7 @@ struct tog_log_view_state {
 	int selected;
 	char *in_repo_path;
 	struct got_repository *repo;
+	struct got_object_id *start_id;
 };
 
 struct tog_blame_cb_args {
@@ -1136,6 +1138,11 @@ open_log_view(struct tog_view *view, struct got_object
 	s->first_displayed_entry = TAILQ_FIRST(&s->commits.head);
 	s->selected_entry = s->first_displayed_entry;
 	s->repo = repo;
+	s->start_id = got_object_id_dup(start_id);
+	if (s->start_id == NULL) {
+		err = got_error_from_errno();
+		goto done;
+	}
 
 	view->show = show_log_view;
 	view->input = input_log_view;
@@ -1154,6 +1161,7 @@ close_log_view(struct tog_view *view)
 		got_commit_graph_close(s->graph);
 	free_commits(&s->commits);
 	free(s->in_repo_path);
+	free(s->start_id);
 	return NULL;
 }
 
@@ -1223,6 +1231,7 @@ input_log_view(struct tog_view **new_view, struct tog_
 {
 	const struct got_error *err = NULL;
 	struct tog_log_view_state *s = &view->state.log;
+	char *parent_path;
 
 	switch (ch) {
 		case 'k':
@@ -1295,6 +1304,22 @@ input_log_view(struct tog_view **new_view, struct tog_
 			err = browse_commit(new_view, view, s->selected_entry,
 			    s->repo);
 			break;
+		case KEY_BACKSPACE:
+			if (strcmp(s->in_repo_path, "/") == 0)
+				break;
+			parent_path = dirname(s->in_repo_path);
+			if (parent_path && strcmp(parent_path, ".") != 0) {
+				struct tog_view *lv;
+				lv = view_open(0, 0, 0, 0, NULL, TOG_VIEW_LOG);
+				if (lv == NULL)
+					return got_error_from_errno();
+				err = open_log_view(lv, s->start_id, s->repo,
+				    parent_path);
+				if (err)
+					break;
+				*new_view = lv;
+			}
+			break;
 		default:
 			break;
 	}