From 3fb06d9095fa254d73886b19b667a1e23aa36e19 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 7 Nov 2026 09:41:20 +0100 Subject: [PATCH] Add a test for a lock error partway through a pull with rebase This has the same problem as an interactive rebase. If pull.rebase is set and a lock stops the rebase partway through, the git command runner runs "git pull" again. This fails with "You are not currently on a branch" because HEAD is detached during the rebase, and the rebase is left stopped halfway. Co-Authored-By: Claude Opus 5.5 --- ..._error_partway_through_pull_with_rebase.go | 80 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 81 insertions(+) create mode 100644 pkg/integration/tests/sync/lock_error_partway_through_pull_with_rebase.go diff --git a/pkg/integration/tests/sync/lock_error_partway_through_pull_with_rebase.go b/pkg/integration/tests/sync/lock_error_partway_through_pull_with_rebase.go new file mode 100644 index 000000000..273f3e9fd --- /dev/null +++ b/pkg/integration/tests/sync/lock_error_partway_through_pull_with_rebase.go @@ -0,0 +1,80 @@ +package sync + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" + "github.com/jesseduffield/lazygit/pkg/integration/tests/shared" +) + +var LockErrorPartwayThroughPullWithRebase = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Pull with a rebase strategy while another git process takes index.lock partway through the rebase", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("file", "content1") + shell.Commit("one") + shell.UpdateFileAndAdd("file", "content2") + shell.Commit("two") + shell.CreateFileAndAdd("file3", "content3") + shell.Commit("three") + + shell.CloneIntoRemote("origin") + + shell.SetBranchUpstream("master", "origin/master") + + shell.HardReset("HEAD^^") + shell.CreateFileAndAdd("file4", "content4") + shell.Commit("four") + shell.CreateFileAndAdd("file5", "content5") + shell.Commit("five") + + shell.SetConfig("pull.rebase", "true") + + // The rebase makes a commit when it picks "four"; the lock then stops + // it when it tries to pick "five". + shared.HoldIndexLockAfterNextCommit(shell) + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Lines( + Contains("five"), + Contains("four"), + Contains("one"), + ) + + t.Views().Status().Content(Equals("↓2↑2 repo → master")) + + t.Views().Files(). + IsFocused(). + Press(keys.Universal.Pull) + + /* EXPECTED: + t.Views().Status().Content(Equals("↑2 repo → master")) + + t.Views().Commits(). + Lines( + Contains("five"), + Contains("four"), + Contains("three"), + Contains("two"), + Contains("one"), + ) + ACTUAL: */ + t.ExpectPopup().Alert(). + Title(Equals("Error")). + Content(Contains("You are not currently on a branch.")). + Confirm() + + t.Views().Commits(). + Lines( + Contains("─── Pending rebase todos"), + Contains("pick").Contains("five"), + Contains("─── Commits"), + Contains("four"), + Contains("three"), + Contains("two"), + Contains("one"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 319966489..ddbfa63bc 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -644,6 +644,7 @@ var tests = []*components.IntegrationTest{ sync.ForcePushMultipleUpstream, sync.ForcePushRemoteBranchNotStoredLocally, sync.ForcePushTriangular, + sync.LockErrorPartwayThroughPullWithRebase, sync.Pull, sync.PullAndSetUpstream, sync.PullMerge,