From 7b5c6f4e124ea1082eed0a14613463343268bdc9 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 14 Sep 2026 10:29:32 +0200 Subject: [PATCH] Demonstrate that the recent repos menu shows ".invalid" for a reftable repo A repo that keeps its refs in a reftable shows ".invalid" in the branch column. Git stores the real HEAD in a binary table there and leaves "ref: refs/heads/.invalid" in the HEAD file, so that anything still reading the HEAD file fails loudly instead of getting a stale answer. We read that file and take the placeholder for a branch name. Co-Authored-By: Claude Opus 5 (1M context) --- .../controllers/helpers/repos_helper_test.go | 13 ++++++ .../tests/misc/recent_repos_reftable_repo.go | 40 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 3 files changed, 54 insertions(+) create mode 100644 pkg/integration/tests/misc/recent_repos_reftable_repo.go diff --git a/pkg/gui/controllers/helpers/repos_helper_test.go b/pkg/gui/controllers/helpers/repos_helper_test.go index 5b6f5bb4b..1bbcd9b6c 100644 --- a/pkg/gui/controllers/helpers/repos_helper_test.go +++ b/pkg/gui/controllers/helpers/repos_helper_test.go @@ -66,6 +66,19 @@ func TestReadHeadInfo(t *testing.T) { expected: headInfo{branch: "mybranch"}, expectedOk: true, }, + { + name: "repo that keeps its refs in a reftable, so HEAD holds a placeholder", + files: map[string]string{ + "repo/.git/HEAD": "ref: refs/heads/.invalid\n", + }, + /* EXPECTED: + repoPath: "repo", + expectedOk: false, + ACTUAL: */ + repoPath: "repo", + expected: headInfo{branch: ".invalid"}, + expectedOk: true, + }, { name: "directory without a .git entry", repoPath: "notarepo", diff --git a/pkg/integration/tests/misc/recent_repos_reftable_repo.go b/pkg/integration/tests/misc/recent_repos_reftable_repo.go new file mode 100644 index 000000000..616681063 --- /dev/null +++ b/pkg/integration/tests/misc/recent_repos_reftable_repo.go @@ -0,0 +1,40 @@ +package misc + +import ( + "path/filepath" + + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var RecentReposReftableRepo = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "The recent repositories menu shows the branch of a repo that keeps its refs in a reftable", + ExtraCmdArgs: []string{}, + ExtraEnvVars: map[string]string{ + "SHOW_RECENT_REPOS": "true", + }, + Skip: false, + GitVersion: AtLeast("2.45.0"), + SetupConfig: func(cfg *config.AppConfig) { + // the first entry is the repo we're in, so it isn't offered + current, _ := filepath.Abs(".") + reftable, _ := filepath.Abs("../reftable") + cfg.GetAppState().RecentRepos = []string{current, reftable} + }, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("one") + shell.RunCommand([]string{"git", "clone", "--ref-format=reftable", ".", "../reftable"}) + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.ExpectPopup().Menu(). + Title(Equals("Recent repositories")). + Lines( + /* EXPECTED: + Contains("reftable").Contains("master").IsSelected(), + ACTUAL: */ + Contains("reftable").Contains(".invalid").IsSelected(), + Contains("Cancel"), + ). + Cancel() + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 89ae48de0..ef73e79b1 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -368,6 +368,7 @@ var tests = []*components.IntegrationTest{ misc.RecentReposBranchColumn, misc.RecentReposColumnWidths, misc.RecentReposOnLaunch, + misc.RecentReposReftableRepo, misc.RecentReposWithLongNames, misc.StartInGitDir, patch_building.Apply,