From 92f10a10c77063de1baf4c221c4736e7eeadcdf1 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Thu, 27 Aug 2026 06:12:13 -1000 Subject: Keep a detached head in the branch switcher --- tests/t0103-log.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh index 41b9769..dfb5176 100755 --- a/tests/t0103-log.sh +++ b/tests/t0103-log.sh @@ -17,6 +17,26 @@ test_expect_success 'generate bar/log' 'cgit_url "bar/log" >tmp' test_expect_success 'find commit 1' 'grep "commit 1" tmp' test_expect_success 'find commit 50' 'grep "commit 50" tmp' +# The switch button submits the select as h, so whatever head the request +# follows has to sit in the list selected, or submitting would quietly move +# the visitor to the first branch. +test_expect_success 'a detached head stays selected in the switcher' ' + sha=$(git -C repos/foo rev-parse master~1) && + cgit_url "foo/log&h=$sha" >tmp && + grep "option value=.$sha. selected" tmp +' +test_expect_success 'a tag head stays selected in the switcher' ' + git -C repos/foo tag t-switch master~1 && + cgit_url "foo/log&h=t-switch" >tmp && + grep "option value=.t-switch. selected>t-switch (detached)" tmp && + git -C repos/foo tag -d t-switch +' +test_expect_success 'a branch head keeps its plain option' ' + cgit_url "foo/log&h=master" >tmp && + grep "option value=.master. selected>master<" tmp && + ! grep "detached" tmp +' + test_expect_success 'generate "with%20space/log?qt=grep&q=commit+1"' ' cgit_url "with+space/log&qt=grep&q=commit+1" >tmp ' -- cgit v2.8.0