Commit 7a2921f9f5de672cb5107b005351dd15771c41c5

Stefan Sperling 2018-07-12T23:48:35

allow blaming parents of commits in tog blame view

diff --git a/tog/tog.1 b/tog/tog.1
index dcd134c..c42a383 100644
--- a/tog/tog.1
+++ b/tog/tog.1
@@ -127,6 +127,11 @@ view for the currently selected line's commit.
 Show the
 .Cm blame
 view for the version of the file in the currently selected line's commit.
+.It Cm p
+Show the
+.Cm blame
+view for the version of the file in the currently selected line's commit's
+parent commit.
 .It Cm B
 Switch the
 .Cm blame
diff --git a/tog/tog.c b/tog/tog.c
index a39d6b3..00d4671 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1563,7 +1563,8 @@ show_blame_view(const char *path, struct got_object_id *commit_id,
 				else if (last_displayed_line < blame.nlines)
 					first_displayed_line++;
 				break;
-			case 'b': {
+			case 'b':
+			case 'p': {
 				struct got_object_id *id;
 				id = get_selected_commit_id(blame.lines,
 				    first_displayed_line, selected_line);
@@ -1577,6 +1578,8 @@ show_blame_view(const char *path, struct got_object_id *commit_id,
 					break;
 				if (pobj == NULL && obj == NULL)
 					break;
+				if (ch == 'p' && pobj == NULL)
+					break;
 				done = 1;
 				if (pthread_mutex_unlock(&mutex) != 0) {
 					err = got_error_from_errno();
@@ -1591,7 +1594,7 @@ show_blame_view(const char *path, struct got_object_id *commit_id,
 				}
 				if (thread_err)
 					break;
-				id = got_object_get_id(obj);
+				id = got_object_get_id(ch == 'b' ? obj : pobj);
 				if (id == NULL) {
 					err = got_error_from_errno();
 					break;