Skip to content

Commit e127a92

Browse files
authored
Bump the minimum required git version to 2.22 (#4439)
- **PR Description** For my current work on better cherry-picking/reverting, git versions older than 2.22 cause considerable headache. Apparently they have issues with `git cherry-pick --continue` and `git cherry-pick --skip` which I would prefer not to have to work around. The last time [we discussed](#2457 (comment)) the question of bumping the minimum version from 2.20 to 2.22, we decided not to because 2.22 is 6 months newer. That was two years ago though, so now it should be fine, I guess.
2 parents 9469037 + bf2d175 commit e127a92

File tree

14 files changed

+15
-44
lines changed

14 files changed

+15
-44
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ jobs:
4949
fail-fast: false
5050
matrix:
5151
git-version:
52-
- 2.20.0 # oldest supported version
53-
- 2.22.5
52+
- 2.22.0 # oldest supported version
5453
- 2.23.0
5554
- 2.25.1
5655
- 2.30.8

pkg/app/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (app *App) validateGitVersion() (*git_commands.GitVersion, error) {
148148
return nil, minVersionError
149149
}
150150

151-
if version.IsOlderThan(2, 20, 0) {
151+
if version.IsOlderThan(2, 22, 0) {
152152
return nil, minVersionError
153153
}
154154

pkg/commands/git_commands/branch_loader.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (self *BranchLoader) Load(reflogCommits []*models.Commit,
7272
onWorker func(func() error),
7373
renderFunc func(),
7474
) ([]*models.Branch, error) {
75-
branches := self.obtainBranches(self.version.IsAtLeast(2, 22, 0))
75+
branches := self.obtainBranches()
7676

7777
if self.AppState.LocalBranchSortOrder == "recency" {
7878
reflogBranches := self.obtainReflogBranches(reflogCommits)
@@ -232,7 +232,7 @@ func (self *BranchLoader) GetBaseBranch(branch *models.Branch, mainBranches *Mai
232232
return split[0], nil
233233
}
234234

235-
func (self *BranchLoader) obtainBranches(canUsePushTrack bool) []*models.Branch {
235+
func (self *BranchLoader) obtainBranches() []*models.Branch {
236236
output, err := self.getRawBranches()
237237
if err != nil {
238238
panic(err)
@@ -255,7 +255,7 @@ func (self *BranchLoader) obtainBranches(canUsePushTrack bool) []*models.Branch
255255
}
256256

257257
storeCommitDateAsRecency := self.AppState.LocalBranchSortOrder != "recency"
258-
return obtainBranch(split, storeCommitDateAsRecency, canUsePushTrack), true
258+
return obtainBranch(split, storeCommitDateAsRecency), true
259259
})
260260
}
261261

@@ -298,7 +298,7 @@ var branchFields = []string{
298298
}
299299

300300
// Obtain branch information from parsed line output of getRawBranches()
301-
func obtainBranch(split []string, storeCommitDateAsRecency bool, canUsePushTrack bool) *models.Branch {
301+
func obtainBranch(split []string, storeCommitDateAsRecency bool) *models.Branch {
302302
headMarker := split[0]
303303
fullName := split[1]
304304
upstreamName := split[2]
@@ -310,12 +310,7 @@ func obtainBranch(split []string, storeCommitDateAsRecency bool, canUsePushTrack
310310

311311
name := strings.TrimPrefix(fullName, "heads/")
312312
aheadForPull, behindForPull, gone := parseUpstreamInfo(upstreamName, track)
313-
var aheadForPush, behindForPush string
314-
if canUsePushTrack {
315-
aheadForPush, behindForPush, _ = parseUpstreamInfo(upstreamName, pushTrack)
316-
} else {
317-
aheadForPush, behindForPush = aheadForPull, behindForPull
318-
}
313+
aheadForPush, behindForPush, _ := parseUpstreamInfo(upstreamName, pushTrack)
319314

320315
recency := ""
321316
if storeCommitDateAsRecency {

pkg/commands/git_commands/branch_loader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func TestObtainBranch(t *testing.T) {
119119

120120
for _, s := range scenarios {
121121
t.Run(s.testName, func(t *testing.T) {
122-
branch := obtainBranch(s.input, s.storeCommitDateAsRecency, true)
122+
branch := obtainBranch(s.input, s.storeCommitDateAsRecency)
123123
assert.EqualValues(t, s.expectedBranch, branch)
124124
})
125125
}

pkg/commands/git_commands/rebase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(opts PrepareInteract
218218
Arg("--keep-empty").
219219
ArgIf(opts.keepCommitsThatBecomeEmpty && self.version.IsAtLeast(2, 26, 0), "--empty=keep").
220220
Arg("--no-autosquash").
221-
ArgIf(self.version.IsAtLeast(2, 22, 0), "--rebase-merges").
221+
Arg("--rebase-merges").
222222
ArgIf(opts.onto != "", "--onto", opts.onto).
223223
Arg(opts.baseHashOrRoot).
224224
ToArgv()

pkg/commands/git_commands/rebase_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,6 @@ func TestRebaseRebaseBranch(t *testing.T) {
5454
assert.NoError(t, err)
5555
},
5656
},
57-
{
58-
testName: "successful rebase (< 2.22.0)",
59-
arg: "master",
60-
gitVersion: &GitVersion{2, 21, 9, ""},
61-
runner: oscommands.NewFakeRunner(t).
62-
ExpectGitArgs([]string{"rebase", "--interactive", "--autostash", "--keep-empty", "--no-autosquash", "master"}, "", nil),
63-
test: func(err error) {
64-
assert.NoError(t, err)
65-
},
66-
},
6757
}
6858

6959
for _, s := range scenarios {

pkg/i18n/english.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ func EnglishTranslationSet() *TranslationSet {
17141714
CreateNewBranchFromCommit: "Create new branch off of commit",
17151715
BuildingPatch: "Building patch",
17161716
ViewCommits: "View commits",
1717-
MinGitVersionError: "Git version must be at least 2.20 (i.e. from 2018 onwards). Please upgrade your git version. Alternatively raise an issue at https://github.com/jesseduffield/lazygit/issues for lazygit to be more backwards compatible.",
1717+
MinGitVersionError: "Git version must be at least 2.22 (i.e. from 2019 onwards). Please upgrade your git version. Alternatively raise an issue at https://github.com/jesseduffield/lazygit/issues for lazygit to be more backwards compatible.",
17181718
RunningCustomCommandStatus: "Running custom command",
17191719
SubmoduleStashAndReset: "Stash uncommitted submodule changes and update",
17201720
AndResetSubmodules: "And reset submodules",

pkg/integration/tests/interactive_rebase/drop_merge_commit.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ var DropMergeCommit = NewIntegrationTest(NewIntegrationTestArgs{
1010
Description: "Drops a merge commit outside of an interactive rebase",
1111
ExtraCmdArgs: []string{},
1212
Skip: false,
13-
GitVersion: AtLeast("2.22.0"), // first version that supports the --rebase-merges option
1413
SetupConfig: func(config *config.AppConfig) {},
1514
SetupRepo: func(shell *Shell) {
1615
shared.CreateMergeCommit(shell)

pkg/integration/tests/interactive_rebase/edit_range_select_down_to_merge_outside_rebase.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ var EditRangeSelectDownToMergeOutsideRebase = NewIntegrationTest(NewIntegrationT
1010
Description: "Select a range of commits (the last one being a merge commit) to edit outside of a rebase",
1111
ExtraCmdArgs: []string{},
1212
Skip: false,
13-
GitVersion: AtLeast("2.22.0"), // first version that supports the --rebase-merges option
1413
SetupConfig: func(config *config.AppConfig) {},
1514
SetupRepo: func(shell *Shell) {
1615
shared.CreateMergeCommit(shell)

pkg/integration/tests/interactive_rebase/edit_range_select_outside_rebase.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ var EditRangeSelectOutsideRebase = NewIntegrationTest(NewIntegrationTestArgs{
1010
Description: "Select a range of commits to edit outside of a rebase",
1111
ExtraCmdArgs: []string{},
1212
Skip: false,
13-
GitVersion: AtLeast("2.22.0"), // first version that supports the --rebase-merges option
1413
SetupConfig: func(config *config.AppConfig) {},
1514
SetupRepo: func(shell *Shell) {
1615
shared.CreateMergeCommit(shell)

0 commit comments

Comments
 (0)