commit c671dc6587800c66e8cbbeaab9336234eec88f69 from: Mark Jamsek date: Mon Apr 24 09:41:17 2023 UTC tog regress: TAB instruction + test for diff J keymap Add the TAB instruction to the test harness, and a test case for the previous commit: scroll down the log from the diff view with the J keymap when on the last loaded commit. ok stsp@ commit - e56a17962a1ed2ed7530c92097d09bde36c57383 commit + c671dc6587800c66e8cbbeaab9336234eec88f69 blob - 04242def3c3bd1f7ec0b24922210fbedced28abb blob + 53edc5c3c79e0951bfdaf8315a353c3430a7b579 --- regress/tog/diff.sh +++ regress/tog/diff.sh @@ -131,6 +131,81 @@ EOF test_done "$testroot" "$ret" } +test_diff_J_keymap_on_last_loaded_commit() +{ + test_init diff_J_keymap_on_last_loaded_commit 94 24 + + local i=0 + + cd $testroot/repo + + while [ "$i" -lt 32 ]; do + echo $i > alpha + git commit -aqm $i + if [ $i -eq 6 ]; then + local id6=$(git_show_head .) + local blobid6=$(get_blob_id . "" alpha) + elif [ $i -eq 7 ]; then + local id7=$(git_show_head .) + local blobid7=$(get_blob_id . "" alpha) + local author_time=$(git_show_author_time .) + fi + i=$(( i + 1 )) + done + + local date=`date -u -r $author_time +"%a %b %e %X %Y UTC"` + + cat <$TOG_TEST_SCRIPT +KEY_ENTER open diff view of selected commit +S toggle horizontal split +TAB tab back to log view +23j move to last loaded commit +KEY_ENTER select last loaded commit +F toggle fullscreen +J move down to next commit in the log +SCREENDUMP +EOF + + cat <$testroot/view.expected +[1/20] diff $id6 $id7 +commit $id7 +from: Flan Hacker +date: $date + +7 + +M alpha | 1+ 1- + +1 file changed, 1 insertion(+), 1 deletion(-) + +commit - $id6 +commit + $id7 +blob - $blobid6 +blob + $blobid7 +--- alpha ++++ alpha +@@ -1 +1 @@ +-6 ++7 + + + +(END) +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_diff_contiguous_commits run_test test_diff_arbitrary_commits +run_test test_diff_J_keymap_on_last_loaded_commit blob - 3be11e9258a6e79e8c65c51e4201e2fe72b26653 blob + 09cd112bc1ff0346edd8a4dd37b64c38e1d41113 --- tog/tog.c +++ tog/tog.c @@ -1649,6 +1649,8 @@ tog_read_script_key(FILE *script, struct tog_view *vie *ch = KEY_DOWN; else if (strncasecmp(line, "KEY_UP", 6) == 0) *ch = KEY_UP; + else if (strncasecmp(line, "TAB", 3) == 0) + *ch = '\t'; else if (strncasecmp(line, "SCREENDUMP", 10) == 0) *ch = TOG_KEY_SCRDUMP; else if (isdigit((unsigned char)*line)) {