allow blaming parents of commits in tog blame 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
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;