@@ -336,74 +336,3 @@ func ParseTreeLine(rd *bufio.Reader, modeBuf, fnameBuf, shaBuf []byte) (mode, fn
336
336
sha = shaBuf
337
337
return
338
338
}
339
-
340
- // ParseTreeLineTree reads a tree entry from a tree in a cat-file --batch stream
341
- //
342
- // This carefully avoids allocations - except where fnameBuf is too small.
343
- // It is recommended therefore to pass in an fnameBuf large enough to avoid almost all allocations
344
- //
345
- // Each line is composed of:
346
- // <mode-in-ascii-dropping-initial-zeros> SP <fname> NUL <20-byte SHA>
347
- //
348
- // We don't attempt to convert the 20-byte SHA to 40-byte SHA to save a lot of time
349
- func ParseTreeLineTree (rd * bufio.Reader , modeBuf , fnameBuf , shaBuf []byte ) (isTree bool , fname , sha []byte , n int , err error ) {
350
- var readBytes []byte
351
-
352
- // Read the Mode & fname
353
- readBytes , err = rd .ReadSlice ('\x00' )
354
- if err != nil {
355
- return
356
- }
357
- if len (readBytes ) < 6 {
358
- log ("missing space in readBytes ParseTreeLineTree: %v" , readBytes )
359
- err = & ErrNotExist {}
360
- return
361
- }
362
- if ! bytes .Equal (readBytes [:6 ], []byte ("40000 " )) {
363
- n += len (readBytes )
364
- for err == bufio .ErrBufferFull {
365
- readBytes , err = rd .ReadSlice ('\x00' )
366
- n += len (readBytes )
367
- }
368
- d := 0
369
- d , err = rd .Discard (20 )
370
- n += d
371
- return
372
- }
373
- isTree = true
374
-
375
- n += 6
376
- readBytes = readBytes [6 :]
377
-
378
- // Deal with the fname
379
- copy (fnameBuf , readBytes )
380
- if len (fnameBuf ) > len (readBytes ) {
381
- fnameBuf = fnameBuf [:len (readBytes )]
382
- } else {
383
- fnameBuf = append (fnameBuf , readBytes [len (fnameBuf ):]... )
384
- }
385
- for err == bufio .ErrBufferFull {
386
- readBytes , err = rd .ReadSlice ('\x00' )
387
- fnameBuf = append (fnameBuf , readBytes ... )
388
- }
389
- n += len (fnameBuf )
390
- if err != nil {
391
- return
392
- }
393
- fnameBuf = fnameBuf [:len (fnameBuf )- 1 ]
394
- fname = fnameBuf
395
-
396
- // Deal with the 20-byte SHA
397
- idx := 0
398
- for idx < 20 {
399
- read := 0
400
- read , err = rd .Read (shaBuf [idx :20 ])
401
- n += read
402
- if err != nil {
403
- return
404
- }
405
- idx += read
406
- }
407
- sha = shaBuf
408
- return
409
- }
0 commit comments