1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-17 00:18:05 +02:00

Use --force instead of --force-with-lease when remote is not stored locally

--force-with-lease simply doesn't work in this case, it will always return a
"stale info" error.
This commit is contained in:
Stefan Haller
2024-05-30 21:08:57 +02:00
parent e93617b1de
commit 116c18e957
3 changed files with 14 additions and 2 deletions

View File

@ -179,6 +179,7 @@ func (self *SyncController) pullWithLock(task gocui.Task, opts PullFilesOptions)
}
type pushOpts struct {
force bool
forceWithLease bool
upstreamRemote string
upstreamBranch string
@ -197,13 +198,14 @@ func (self *SyncController) pushAux(currentBranch *models.Branch, opts pushOpts)
err := self.c.Git().Sync.Push(
task,
git_commands.PushOpts{
Force: opts.force,
ForceWithLease: opts.forceWithLease,
UpstreamRemote: opts.upstreamRemote,
UpstreamBranch: opts.upstreamBranch,
SetUpstream: opts.setUpstream,
})
if err != nil {
if !opts.forceWithLease && strings.Contains(err.Error(), "Updates were rejected") {
if !opts.force && !opts.forceWithLease && strings.Contains(err.Error(), "Updates were rejected") {
if opts.remoteBranchStoredLocally {
return errors.New(self.c.Tr.UpdatesRejected)
}
@ -217,7 +219,7 @@ func (self *SyncController) pushAux(currentBranch *models.Branch, opts pushOpts)
Prompt: self.forcePushPrompt(),
HandleConfirm: func() error {
newOpts := opts
newOpts.forceWithLease = true
newOpts.force = true
return self.pushAux(currentBranch, newOpts)
},