@@ -2268,16 +2268,16 @@ export class Repository implements Disposable {
22682268 } ) ;
22692269 }
22702270
2271- async popStash ( index ?: number ) : Promise < void > {
2272- return await this . run ( Operation . Stash , ( ) => this . repository . popStash ( index ) ) ;
2271+ async popStash ( index ?: number , options ?: { reinstateStagedChanges ?: boolean } ) : Promise < void > {
2272+ return await this . run ( Operation . Stash , ( ) => this . repository . popStash ( index , options ) ) ;
22732273 }
22742274
22752275 async dropStash ( index ?: number ) : Promise < void > {
22762276 return await this . run ( Operation . Stash , ( ) => this . repository . dropStash ( index ) ) ;
22772277 }
22782278
2279- async applyStash ( index ?: number ) : Promise < void > {
2280- return await this . run ( Operation . Stash , ( ) => this . repository . applyStash ( index ) ) ;
2279+ async applyStash ( index ?: number , options ?: { reinstateStagedChanges ?: boolean } ) : Promise < void > {
2280+ return await this . run ( Operation . Stash , ( ) => this . repository . applyStash ( index , options ) ) ;
22812281 }
22822282
22832283 async showStash ( index : number ) : Promise < Change [ ] | undefined > {
@@ -2500,17 +2500,16 @@ export class Repository implements Disposable {
25002500 }
25012501 }
25022502
2503- const stashName = `migration- ${ sourceRepository . HEAD ?. name ?? sourceRepository . HEAD ?. commit } -${ this . HEAD ?. name ?? this . HEAD ?. commit } ` ;
2503+ const stashName = `migration: ${ sourceRepository . HEAD ?. name ?? sourceRepository . HEAD ?. commit } -${ this . HEAD ?. name ?? this . HEAD ?. commit } ` ;
25042504 await sourceRepository . createStash ( stashName , options ?. untracked ) ;
25052505 const stashes = await sourceRepository . getStashes ( ) ;
25062506
25072507 try {
2508- await this . applyStash ( stashes [ 0 ] . index ) ;
2509-
25102508 if ( options ?. deleteFromSource ) {
2511- await sourceRepository . dropStash ( stashes [ 0 ] . index ) ;
2509+ await this . popStash ( stashes [ 0 ] . index ) ;
25122510 } else {
2513- await sourceRepository . popStash ( ) ;
2511+ await this . applyStash ( stashes [ 0 ] . index ) ;
2512+ await sourceRepository . popStash ( stashes [ 0 ] . index , { reinstateStagedChanges : true } ) ;
25142513 }
25152514 } catch ( err ) {
25162515 if ( err . gitErrorCode === GitErrorCodes . StashConflict ) {
@@ -2523,11 +2522,11 @@ export class Repository implements Disposable {
25232522 await commands . executeCommand ( 'workbench.view.scm' ) ;
25242523 }
25252524
2526- await sourceRepository . popStash ( ) ;
2525+ await sourceRepository . popStash ( stashes [ 0 ] . index , { reinstateStagedChanges : true } ) ;
25272526 return ;
25282527 }
25292528
2530- await sourceRepository . popStash ( ) ;
2529+ await sourceRepository . popStash ( stashes [ 0 ] . index , { reinstateStagedChanges : true } ) ;
25312530 throw err ;
25322531 }
25332532 }
@@ -2872,7 +2871,7 @@ export class Repository implements Disposable {
28722871 const result = await runOperation ( ) ;
28732872 return result ;
28742873 } finally {
2875- await this . repository . popStash ( ) ;
2874+ await this . repository . popStash ( undefined , { reinstateStagedChanges : true } ) ;
28762875 }
28772876 }
28782877
0 commit comments