@@ -142,7 +142,7 @@ export class DataSource implements vscode.Disposable {
142
142
this . getRefs ( repo , showRemoteBranches , hideRemotes ) . then ( ( refData : GitRefData ) => refData , ( errorMessage : string ) => errorMessage ) ,
143
143
this . getStashes ( repo )
144
144
] ) . then ( async ( results ) => {
145
- let commits : GitCommitRecord [ ] = results [ 0 ] , refData : GitRefData | string = results [ 1 ] , stashes : GitStash [ ] = results [ 2 ] , i , unsavedChanges = null ;
145
+ let commits : GitCommitRecord [ ] = results [ 0 ] , refData : GitRefData | string = results [ 1 ] , stashes : GitStash [ ] = results [ 2 ] , i ;
146
146
let moreCommitsAvailable = commits . length === maxCommits + 1 ;
147
147
if ( moreCommitsAvailable ) commits . pop ( ) ;
148
148
@@ -158,12 +158,12 @@ export class DataSource implements vscode.Disposable {
158
158
}
159
159
}
160
160
161
- if ( refData . head !== null ) {
161
+ if ( refData . head !== null && config . showUncommittedChanges ) {
162
162
for ( i = 0 ; i < commits . length ; i ++ ) {
163
163
if ( refData . head === commits [ i ] . hash ) {
164
- unsavedChanges = config . showUncommittedChanges ? await this . getUnsavedChanges ( repo ) : null ;
165
- if ( unsavedChanges !== null ) {
166
- commits . unshift ( { hash : UNCOMMITTED , parents : [ refData . head ] , author : '*' , email : '' , date : Math . round ( ( new Date ( ) ) . getTime ( ) / 1000 ) , message : 'Uncommitted Changes (' + unsavedChanges . changes + ')' } ) ;
164
+ const numUncommittedChanges = await this . getUncommittedChanges ( repo ) ;
165
+ if ( numUncommittedChanges > 0 ) {
166
+ commits . unshift ( { hash : UNCOMMITTED , parents : [ refData . head ] , author : '*' , email : '' , date : Math . round ( ( new Date ( ) ) . getTime ( ) / 1000 ) , message : 'Uncommitted Changes (' + numUncommittedChanges + ')' } ) ;
167
167
}
168
168
break ;
169
169
}
@@ -1287,16 +1287,14 @@ export class DataSource implements vscode.Disposable {
1287
1287
}
1288
1288
1289
1289
/**
1290
- * Get the unsaved changes summary of a repository.
1290
+ * Get the number of uncommitted changes in a repository.
1291
1291
* @param repo The path of the repository.
1292
- * @returns The unsaved changes summary .
1292
+ * @returns The number of uncommitted changes .
1293
1293
*/
1294
- private getUnsavedChanges ( repo : string ) {
1295
- return this . spawnGit < GitUnsavedChanges | null > ( [ 'status' , '-s' , '--branch' , '--untracked-files' , '--porcelain' ] , repo , ( stdout ) => {
1296
- let lines = stdout . split ( EOL_REGEX ) ;
1297
- return lines . length > 2
1298
- ? { branch : lines [ 0 ] . substring ( 3 ) . split ( '...' ) [ 0 ] , changes : lines . length - 2 }
1299
- : null ;
1294
+ private getUncommittedChanges ( repo : string ) {
1295
+ return this . spawnGit ( [ 'status' , '--untracked-files' , '--porcelain' ] , repo , ( stdout ) => {
1296
+ const numLines = stdout . split ( EOL_REGEX ) . length ;
1297
+ return numLines > 1 ? numLines - 1 : 0 ;
1300
1298
} ) ;
1301
1299
}
1302
1300
@@ -1625,8 +1623,3 @@ interface GitTagDetailsData {
1625
1623
message : string ;
1626
1624
error : ErrorInfo ;
1627
1625
}
1628
-
1629
- interface GitUnsavedChanges {
1630
- branch : string ;
1631
- changes : number ;
1632
- }
0 commit comments