@@ -994,13 +994,10 @@ function parseGitStashes(raw: string): Stash[] {
994
994
return result ;
995
995
}
996
996
997
- // TODO@lszomoru - adopt in diffFiles()
998
997
function parseGitChanges ( repositoryRoot : string , raw : string ) : Change [ ] {
999
998
let index = 0 ;
1000
999
const result : Change [ ] = [ ] ;
1001
- const segments = raw . trim ( )
1002
- . split ( '\x00' )
1003
- . filter ( s => s ) ;
1000
+ const segments = raw . trim ( ) . split ( '\x00' ) . filter ( s => s ) ;
1004
1001
1005
1002
segmentsLoop:
1006
1003
while ( index < segments . length - 1 ) {
@@ -1492,70 +1489,7 @@ export class Repository {
1492
1489
return [ ] ;
1493
1490
}
1494
1491
1495
- const entries = gitResult . stdout . split ( '\x00' ) ;
1496
- let index = 0 ;
1497
- const result : Change [ ] = [ ] ;
1498
-
1499
- entriesLoop:
1500
- while ( index < entries . length - 1 ) {
1501
- const change = entries [ index ++ ] ;
1502
- const resourcePath = entries [ index ++ ] ;
1503
- if ( ! change || ! resourcePath ) {
1504
- break ;
1505
- }
1506
-
1507
- const originalUri = Uri . file ( path . isAbsolute ( resourcePath ) ? resourcePath : path . join ( this . repositoryRoot , resourcePath ) ) ;
1508
- let status : Status = Status . UNTRACKED ;
1509
-
1510
- // Copy or Rename status comes with a number, e.g. 'R100'. We don't need the number, so we use only first character of the status.
1511
- switch ( change [ 0 ] ) {
1512
- case 'M' :
1513
- status = Status . MODIFIED ;
1514
- break ;
1515
-
1516
- case 'A' :
1517
- status = Status . INDEX_ADDED ;
1518
- break ;
1519
-
1520
- case 'D' :
1521
- status = Status . DELETED ;
1522
- break ;
1523
-
1524
- // Rename contains two paths, the second one is what the file is renamed/copied to.
1525
- case 'R' : {
1526
- if ( index >= entries . length ) {
1527
- break ;
1528
- }
1529
-
1530
- const newPath = entries [ index ++ ] ;
1531
- if ( ! newPath ) {
1532
- break ;
1533
- }
1534
-
1535
- const uri = Uri . file ( path . isAbsolute ( newPath ) ? newPath : path . join ( this . repositoryRoot , newPath ) ) ;
1536
- result . push ( {
1537
- uri,
1538
- renameUri : uri ,
1539
- originalUri,
1540
- status : Status . INDEX_RENAMED
1541
- } ) ;
1542
-
1543
- continue ;
1544
- }
1545
- default :
1546
- // Unknown status
1547
- break entriesLoop;
1548
- }
1549
-
1550
- result . push ( {
1551
- status,
1552
- originalUri,
1553
- uri : originalUri ,
1554
- renameUri : originalUri ,
1555
- } ) ;
1556
- }
1557
-
1558
- return result ;
1492
+ return parseGitChanges ( this . repositoryRoot , gitResult . stdout ) ;
1559
1493
}
1560
1494
1561
1495
async getMergeBase ( ref1 : string , ref2 : string ) : Promise < string | undefined > {
0 commit comments