1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-23 12:18:51 +02:00

Handle scanner error in RunAndProcessLines

Scanners can return errors (e.g. ErrTooLong), and if we don't handle it, the
cmd.Wait() call below will block forever because nobody drains the command's
output.

This happens for CommitLoader.GetCommits when there's a commit whose subject
line is longer than approx. 65500 characters; in that case, lazygit would lock
up completely. With this fix it remains usable, but the commit list is truncated
before the bad commit, which is not good enough. We'll improve that in the
remaining commits of this branch.
This commit is contained in:
Stefan Haller 2024-04-27 15:55:30 +02:00
parent 5558d873af
commit 6bb8c180b2

@ -178,6 +178,11 @@ func (self *cmdObjRunner) RunAndProcessLines(cmdObj ICmdObj, onLine func(line st
} }
} }
if scanner.Err() != nil {
_ = Kill(cmd)
return scanner.Err()
}
_ = cmd.Wait() _ = cmd.Wait()
self.log.Infof("%s (%s)", cmdObj.ToString(), time.Since(t)) self.log.Infof("%s (%s)", cmdObj.ToString(), time.Since(t))