Skip to content

Rewording last commit freezes when GPG passphrase is needed in CLI #3806

@Neko-Box-Coder

Description

@Neko-Box-Coder

Describe the bug
When you have GPG passphrase setup to be prompt in CLI, it will hang indefinitely when trying to reword the last commit. No input can reach the gpg prompt.

While it works when you just want to do a normal commit.

To Reproduce
Steps to reproduce the behavior:

  1. Have your GPG setup with passphrase, see here
  2. Change GPG to ask passphrase in CLI by having pinentry-mode loopback in ~/.gnupg/gpg.conf
  3. Maybe restart your gpg agent by doing gpg-connect-agent reloadagent /bye
  4. Reword the last commit in a repo by going to the Commits panel and press r on the last commit
  5. Type your reworded message and press enter
  6. See it asks for passphrase on top of lazygit TUI

Expected behavior
You should be able to enter your passphrase and submit it to GPG prompt.

Screenshots
image

Version info:
commit=v0.42.0, build date=2024-05-19T10:54:29Z, build source=binaryRelease, version=0.42.0, os=linux, arch=amd64, git version=2.45.2

Additional context
This relates #3758 and #30.

It seems like it goes through the same code path as rebasing which does not have explicit GPG support.

The line in question is in here:

func (self *RebaseCommands) RewordCommit(commits []*models.Commit, index int, summary string, description string) error {
if models.IsHeadCommit(commits, index) {
// we've selected the top commit so no rebase is required
return self.commit.RewordLastCommit(summary, description)
}

GPG works fine when committing normally, it goes to a different code path which can handle gpg.

func (self *WorkingTreeHelper) handleCommit(summary string, description string) error {
cmdObj := self.c.Git().Commit.CommitCmdObj(summary, description)
self.c.LogAction(self.c.Tr.Actions.Commit)
return self.gpgHelper.WithGpgHandling(cmdObj, self.c.Tr.CommittingStatus, func() error {
self.commitsHelper.OnCommitSuccess()
return nil
})
}

The question is just to access gpghelper from RebaseCommands and wrap the commands using gpghelper.

Maybe I can try to figure it out this weekend or this month when I am free, could also see if I can add initial gpg support to rebasing as mentioned here.

func (self *RebaseCommands) BeginInteractiveRebaseForCommitRange(
commits []*models.Commit, start, end int, keepCommitsThatBecomeEmpty bool,
) error {
if len(commits)-1 < end {
return errors.New("index outside of range of commits")
}
// we can make this GPG thing possible it just means we need to do this in two parts:
// one where we handle the possibility of a credential request, and the other
// where we continue the rebase
if self.config.UsingGpg() {
return errors.New(self.Tr.DisabledForGPG)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions