Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Neko-Box-Coder opened this issue Aug 7, 2024 · 1 comment · Fixed by #3815
Closed

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

Neko-Box-Coder opened this issue Aug 7, 2024 · 1 comment · Fixed by #3815
Labels
bug Something isn't working

Comments

@Neko-Box-Coder
Copy link
Contributor

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)
}

@Neko-Box-Coder Neko-Box-Coder added the bug Something isn't working label Aug 7, 2024
@Neko-Box-Coder Neko-Box-Coder changed the title Rewording last commit hangs freezes when GPG passphrase is needed in CLI Rewording last commit freezes when GPG passphrase is needed in CLI Aug 7, 2024
@stefanhaller
Copy link
Collaborator

An easier fix is probably to make the distinction of "is this the head commit" at the call site of RebaseCommands.RewordCommit (in LocalCommitsController.handleReword) rather than inside it. LocalCommitsController has access to the gpgHelper. This would then be similar to what we already do for Amend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants