@@ -203,7 +203,16 @@ headerLoop:
203203 }
204204
205205 // Discard the rest of the tag
206- return id , DiscardFull (rd , size - n + 1 )
206+ discard := size - n + 1
207+ for discard > math .MaxInt32 {
208+ _ , err := rd .Discard (math .MaxInt32 )
209+ if err != nil {
210+ return id , err
211+ }
212+ discard -= math .MaxInt32
213+ }
214+ _ , err := rd .Discard (int (discard ))
215+ return id , err
207216}
208217
209218// ReadTreeID reads a tree ID from a cat-file --batch stream, throwing away the rest of the stream.
@@ -229,7 +238,16 @@ headerLoop:
229238 }
230239
231240 // Discard the rest of the commit
232- return id , DiscardFull (rd , size - n + 1 )
241+ discard := size - n + 1
242+ for discard > math .MaxInt32 {
243+ _ , err := rd .Discard (math .MaxInt32 )
244+ if err != nil {
245+ return id , err
246+ }
247+ discard -= math .MaxInt32
248+ }
249+ _ , err := rd .Discard (int (discard ))
250+ return id , err
233251}
234252
235253// git tree files are a list:
@@ -327,21 +345,3 @@ func init() {
327345 _ , filename , _ , _ := runtime .Caller (0 )
328346 callerPrefix = strings .TrimSuffix (filename , "modules/git/batch_reader.go" )
329347}
330-
331- func DiscardFull (rd * bufio.Reader , discard int64 ) error {
332- if discard > math .MaxInt32 {
333- n , err := rd .Discard (math .MaxInt32 )
334- discard -= int64 (n )
335- if err != nil {
336- return err
337- }
338- }
339- for discard > 0 {
340- n , err := rd .Discard (int (discard ))
341- discard -= int64 (n )
342- if err != nil {
343- return err
344- }
345- }
346- return nil
347- }
0 commit comments