File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -30,9 +30,11 @@ type Parser struct {
3030func NewParser (r io.Reader , format Format ) * Parser {
3131 scanner := bufio .NewScanner (r )
3232
33- // default MaxScanTokenSize = 64 kiB may be too small for some references,
34- // so allow the buffer to grow up to 4x if needed
35- scanner .Buffer (nil , 4 * bufio .MaxScanTokenSize )
33+ // default Scanner.MaxScanTokenSize = 64 kiB may be too small for some references,
34+ // so allow the buffer to be large enough in case the ref has long content (e.g.: a tag with long message)
35+ // as long as it doesn't exceed some reasonable limit (4 MiB here, or MAX_DISPLAY_FILE_SIZE=8MiB), it is OK
36+ // there are still some choices: 1. add a config option for the limit; 2. don't use scanner and write our own parser to fully handle large contents
37+ scanner .Buffer (nil , 4 * 1024 * 1024 )
3638
3739 // in addition to the reference delimiter we specified in the --format,
3840 // `git for-each-ref` will always add a newline after every reference.
You can’t perform that action at this time.
0 commit comments