commit eb7ebd1cb08a207935fadc4f17e8c31cb6dca13b from: Mark Jamsek via: Thomas Adam date: Fri Jan 3 10:46:48 2025 UTC tog: don't mark incorrect base commit in nested log views If a nested log view is opened, don't reuse the work tree's base commit index from the initial `tog log` invocation because it is based on the initial commit queue. If it has become invalid, an incorrect log view commit entry is painted with the base commit marker. Reset the index whenever opening nested log views so that it is recomputed, and write a regression test to cover this case. ok stsp@ commit - 1ac1d978352cb39038cfb80296e30c739a72ac05 commit + eb7ebd1cb08a207935fadc4f17e8c31cb6dca13b blob - 5329319eb952b701fc799caf6f0648c80bd83b52 blob + 01a33201435af4ba4c618c10db784372be30bea2 --- regress/tog/log.sh +++ regress/tog/log.sh @@ -542,7 +542,7 @@ test_log_commit_keywords() test_log_show_base_commit() { # make view wide enough to show full headline - test_init log_show_base_commit 80 3 + test_init log_show_base_commit 80 4 local repo="$testroot/repo" local id=$(git_show_head "$repo") @@ -574,6 +574,7 @@ test_log_show_base_commit() $(trim 80 "commit $head_id [1/2] master") $ymd flan_hacker *[master] base commit $ymd flan_hacker adding the test tree + EOF tog log @@ -590,6 +591,7 @@ test_log_show_base_commit() $(trim 80 "commit $head_id [1/2] master") $ymd flan_hacker [master] base commit $ymd flan_hacker adding the test tree + EOF tog log -r "$repo" @@ -615,6 +617,7 @@ test_log_show_base_commit() $(trim 80 "commit $head_id [1/3] master") $ymd flan_hacker ~[master] new base mixed-commit $ymd flan_hacker base commit + $ymd flan_hacker adding the test tree EOF tog log @@ -625,7 +628,31 @@ test_log_show_base_commit() test_done "$testroot" "$ret" return 1 fi + + # check marker is not incorrectly drawn when opening a nested log view + cat <<-EOF >$TOG_TEST_SCRIPT + T # open tree view of base commit + j # select beta tree entry + L # load log view of commits involving beta + SCREENDUMP + EOF + cat <<-EOF >$testroot/view.expected + $(trim 80 "commit $id /beta [1/1]") + $ymd 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_done "$testroot" "$ret" } blob - 40d9d440f0ca6f4c9a2f302aebab7ffa7ffa680a blob + c76a5f2663c1570b0f625e29396a6d50df6fa6a9 --- tog/tog.c +++ tog/tog.c @@ -11309,6 +11309,7 @@ view_dispatch_request(struct tog_view **new_view, stru "parent/child view pair not supported"); break; case TOG_VIEW_LOG: + tog_base_commit.idx = -1; if (view->type == TOG_VIEW_BLAME) err = log_annotated_line(new_view, y, x, view->state.blame.repo, view->state.blame.id_to_log);