Download raw body.
add tog log 't' keymap to diff arbitrary commits
Stefan Sperling <stsp@stsp.name> wrote:
> On Thu, Aug 08, 2024 at 08:41:39PM +1000, Mark Jamsek wrote:
> > Updated diff actually changes the keymap from 't' to 'm'.
>
> ok by me.
>
> I see no reason to prevent this change from going in already.
> It's self-contained, has little chance of breaking anything and
> adds value. I am happy with this.
>
> Would be nice to have some tests, too, as always.
Here's basic regress for the new tog 'm' keymap covering (un)marking
arbitrary commits, overwriting base commit marker, and rendering a diff
view of marked and selected commits.
There's also a tiny change where I missed using the local convenience
pointer reaching into struct tog_log_view_state
-----------------------------------------------
commit f578305d3f521e17026e0f58c181ccbf069222ed
from: Mark Jamsek <mark@jamsek.dev>
date: Fri Aug 9 10:00:04 2024 UTC
tog: regress test for new log view 'm'ark commit keymap
M regress/tog/log.sh | 159+ 0-
1 file changed, 159 insertions(+), 0 deletions(-)
diff 56a06f969c4e00bcb0c197b33eef7c5fe8f360a8 f578305d3f521e17026e0f58c181ccbf069222ed
commit - 56a06f969c4e00bcb0c197b33eef7c5fe8f360a8
commit + f578305d3f521e17026e0f58c181ccbf069222ed
blob - 58c10dafb6236aba27ddab7d849f0e5fbb825d8b
blob + f61a9bee3dba8a664892a50235335ed634ef92bd
--- regress/tog/log.sh
+++ regress/tog/log.sh
@@ -726,6 +726,164 @@ test_log_search()
test_done "$testroot" "$ret"
}
+test_log_mark_keymap()
+{
+ test_init log_mark_keymap 141 10
+
+ local repo="$testroot/repo"
+ local wt="$testroot/wt"
+ local id_root=$(git_show_head $repo)
+ local prefix_root=$(trim_obj_id 8 $id_root)
+ local author_time=$(git_show_author_time $repo)
+ local ymd_root=$(date -u -r $author_time +"%F")
+ local alpha_root=$(get_blob_id $testroot/repo "" alpha)
+
+ got checkout "$repo" "$wt" > /dev/null
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "got checkout failed unexpectedly"
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ cd "$wt"
+
+ echo "new alpha" > alpha
+ got commit -m "new alpha" > /dev/null
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "got commit failed unexpectedly" >&2
+ test_done "$testroot" $ret
+ return 1
+ fi
+
+ author_time=$(git_show_author_time $repo)
+ local ymd_head=$(date -u -r $author_time +"%F")
+ local id_head=$(git_show_head $repo)
+ local prefix_head=$(trim_obj_id 8 $id_head)
+ local alpha_head=$(get_blob_id $testroot/repo "" alpha)
+
+ # test marker is correctly applied to arbitrary commit
+ cat <<-EOF >$TOG_TEST_SCRIPT
+ j
+ m mark commit
+ SCREENDUMP
+ EOF
+
+ cat <<-EOF >$testroot/view.expected
+ commit $id_root [2/2]
+ $ymd_head $prefix_head flan_hacker ~[master] new alpha
+ $ymd_root $prefix_root flan_hacker >adding the test tree
+
+
+
+
+
+
+
+ EOF
+
+ tog log
+ cmp -s $testroot/view.expected $testroot/view
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/view.expected $testroot/view
+ test_done "$testroot" $ret
+ return 1
+ fi
+
+ # test commit is correctly unmarked
+ cat <<-EOF >$TOG_TEST_SCRIPT
+ j
+ m mark commit
+ m unmark commit
+ SCREENDUMP
+ EOF
+
+ cat <<-EOF >$testroot/view.expected
+ commit $id_root [2/2]
+ $ymd_head $prefix_head flan_hacker ~[master] new alpha
+ $ymd_root $prefix_root flan_hacker adding the test tree
+
+
+
+
+
+
+
+ EOF
+
+ tog log
+ cmp -s $testroot/view.expected $testroot/view
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/view.expected $testroot/view
+ test_done "$testroot" $ret
+ return 1
+ fi
+
+ # test marker correctly overwrites base commit marker
+ cat <<-EOF >$TOG_TEST_SCRIPT
+ m mark commit
+ SCREENDUMP
+ EOF
+
+ cat <<-EOF >$testroot/view.expected
+ commit $id_head [1/2] master
+ $ymd_head $prefix_head flan_hacker >[master] new alpha
+ $ymd_root $prefix_root flan_hacker adding the test tree
+
+
+
+
+
+
+
+ EOF
+
+ tog log
+ cmp -s $testroot/view.expected $testroot/view
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/view.expected $testroot/view
+ test_done "$testroot" $ret
+ return 1
+ fi
+
+ # test diff of marked and selected commit is correctly rendered
+ cat <<-EOF >$TOG_TEST_SCRIPT
+ m mark commit
+ j
+ KEY_ENTER show diff of marked and root commit
+ F toggle fullscreen
+ SCREENDUMP
+ EOF
+
+ cat <<-EOF >$testroot/view.expected
+ [1/10] diff $id_head $id_root
+ commit - $id_head
+ commit + $id_root
+ blob - $alpha_head
+ blob + $alpha_root
+ --- alpha
+ +++ alpha
+ @@ -1 +1 @@
+ -new alpha
+ +alpha
+ EOF
+
+ tog log
+ cmp -s $testroot/view.expected $testroot/view
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/view.expected $testroot/view
+ test_done "$testroot" $ret
+ return 1
+ fi
+
+ test_done "$testroot" $ret
+}
+
test_parseargs "$@"
run_test test_log_hsplit_diff
run_test test_log_vsplit_diff
@@ -738,3 +896,4 @@ run_test test_log_commit_keywords
run_test test_log_show_base_commit
run_test test_log_limit_view
run_test test_log_search
+run_test test_log_mark_keymap
-----------------------------------------------
commit 56a06f969c4e00bcb0c197b33eef7c5fe8f360a8
from: Mark Jamsek <mark@jamsek.dev>
date: Fri Aug 9 10:00:01 2024 UTC
use local temporary convenience pointer missed in 28c5a8280b
M tog/tog.c | 1+ 1-
1 file changed, 1 insertion(+), 1 deletion(-)
diff 7e18255791187735b9e36951caa895974e4e9ba3 56a06f969c4e00bcb0c197b33eef7c5fe8f360a8
commit - 7e18255791187735b9e36951caa895974e4e9ba3
commit + 56a06f969c4e00bcb0c197b33eef7c5fe8f360a8
blob - f9ce0c8c3d60e68ea2f44223560be407416f477a
blob + dbbaf92a90b365370c465e5011b8410a7a8d6c18
--- tog/tog.c
+++ tog/tog.c
@@ -3200,7 +3200,7 @@ open_diff_view_for_commit(struct tog_view **new_view,
if (ls != NULL && ls->marked_entry != NULL &&
ls->marked_entry != ls->selected_entry)
- parent_id = log_view->state.log.marked_entry->id;
+ parent_id = ls->marked_entry->id;
else if ((p = STAILQ_FIRST(got_object_commit_get_parent_ids(commit))))
parent_id = &p->id;
else
--
Mark Jamsek <https://bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68
add tog log 't' keymap to diff arbitrary commits