summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-04-27 15:55:30 +0200
committerStefan Haller <stefan@haller-berlin.de>2024-05-15 13:27:01 +0200
commit6bb8c180b2c44911775cd045b8c90a916de738d9 (patch)
tree936341eda1435ac06b3128452459e5e5e59247f3 /pkg
parent5558d873aff7c73e03a199fb31c344ddf83325c3 (diff)
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.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/commands/oscommands/cmd_obj_runner.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/pkg/commands/oscommands/cmd_obj_runner.go b/pkg/commands/oscommands/cmd_obj_runner.go
index 296850e32..5f28196e3 100644
--- a/pkg/commands/oscommands/cmd_obj_runner.go
+++ b/pkg/commands/oscommands/cmd_obj_runner.go
@@ -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()
self.log.Infof("%s (%s)", cmdObj.ToString(), time.Since(t))