@@ -231,7 +231,7 @@ export class PushGitCommand extends QuickCommand<State> {
231231 { placeholder : 'Cannot publish; No remotes found' } ,
232232 ) ;
233233 }
234- } else if ( branch != null && branch ?. state . behind > 0 ) {
234+ } else if ( branch ?. upstream ?. state . behind ) {
235235 step = this . createConfirmStep (
236236 appendReposToTitle ( `Confirm ${ context . title } ` , state , context ) ,
237237 [
@@ -254,11 +254,13 @@ export class PushGitCommand extends QuickCommand<State> {
254254 : useForceWithLease
255255 ? ' (with lease)'
256256 : ''
257- } ${ branch ?. state . ahead ? ` ${ pluralize ( 'commit' , branch . state . ahead ) } ` : '' } ${
258- branch . getRemoteName ( ) ? ` to ${ branch . getRemoteName ( ) } ` : ''
259- } ${
260- branch != null && branch . state . behind > 0
261- ? `, overwriting ${ pluralize ( 'commit' , branch . state . behind ) } ${
257+ } ${
258+ branch ?. upstream . state . ahead
259+ ? ` ${ pluralize ( 'commit' , branch . upstream . state . ahead ) } `
260+ : ''
261+ } ${ branch . getRemoteName ( ) ? ` to ${ branch . getRemoteName ( ) } ` : '' } ${
262+ branch != null && branch . upstream . state . behind > 0
263+ ? `, overwriting ${ pluralize ( 'commit' , branch . upstream . state . behind ) } ${
262264 branch ?. getRemoteName ( ) ? ` on ${ branch . getRemoteName ( ) } ` : ''
263265 } `
264266 : ''
@@ -269,16 +271,20 @@ export class PushGitCommand extends QuickCommand<State> {
269271 label : `Cancel ${ this . title } ` ,
270272 detail : `Cannot push; ${ getReferenceLabel (
271273 branch ,
272- ) } is behind ${ branch . getRemoteName ( ) } by ${ pluralize ( 'commit' , branch . state . behind ) } `,
274+ ) } is behind ${ branch . getRemoteName ( ) } by ${ pluralize (
275+ 'commit' ,
276+ branch . upstream . state . behind ,
277+ ) } `,
273278 } ) ,
274279 ) ;
275- } else if ( branch != null && branch ?. state . ahead > 0 ) {
280+ } else if ( branch ?. upstream ?. state . ahead ) {
276281 step = this . createConfirmStep ( appendReposToTitle ( `Confirm ${ context . title } ` , state , context ) , [
277282 createFlagsQuickPickItem < Flags > ( state . flags , [ branch . getRemoteName ( ) ! ] , {
278283 label : this . title ,
279- detail : `Will push ${ pluralize ( 'commit' , branch . state . ahead ) } from ${ getReferenceLabel (
280- branch ,
281- ) } to ${ branch . getRemoteName ( ) } `,
284+ detail : `Will push ${ pluralize (
285+ 'commit' ,
286+ branch . upstream . state . ahead ,
287+ ) } from ${ getReferenceLabel ( branch ) } to ${ branch . getRemoteName ( ) } `,
282288 } ) ,
283289 ] ) ;
284290 } else {
@@ -304,7 +310,7 @@ export class PushGitCommand extends QuickCommand<State> {
304310 repoPath : repo . path ,
305311 } ;
306312
307- if ( status ?. state . ahead === 0 ) {
313+ if ( status ?. upstream ?. state . ahead === 0 ) {
308314 if ( ! isBranchReference ( state . reference ) && status . upstream == null ) {
309315 let pushDetails ;
310316
@@ -376,22 +382,22 @@ export class PushGitCommand extends QuickCommand<State> {
376382 let pushDetails ;
377383 if ( state . reference != null ) {
378384 pushDetails = `${
379- status ?. state . ahead
385+ status ?. upstream ?. state . ahead
380386 ? ` commits up to and including ${ getReferenceLabel ( state . reference , {
381387 label : false ,
382388 } ) } `
383389 : ''
384390 } ${ status ?. upstream ? ` to ${ getRemoteNameFromBranchName ( status . upstream ?. name ) } ` : '' } `;
385391 } else {
386- pushDetails = `${ status ?. state . ahead ? ` ${ pluralize ( 'commit' , status . state . ahead ) } ` : '' } ${
387- status ?. upstream ? ` to ${ getRemoteNameFromBranchName ( status . upstream ?. name ) } ` : ''
388- } `;
392+ pushDetails = `${
393+ status ?. upstream ?. state . ahead ? ` ${ pluralize ( 'commit' , status . upstream . state . ahead ) } ` : ''
394+ } ${ status ?. upstream ? ` to ${ getRemoteNameFromBranchName ( status . upstream ?. name ) } ` : '' } `;
389395 }
390396
391397 step = this . createConfirmStep (
392398 appendReposToTitle ( `Confirm ${ context . title } ` , state , context , lastFetchedOn ) ,
393399 [
394- ...( status ?. state . behind
400+ ...( status ?. upstream ?. state . behind
395401 ? [ ]
396402 : [
397403 createFlagsQuickPickItem < Flags > ( state . flags , [ ] , {
@@ -419,8 +425,8 @@ export class PushGitCommand extends QuickCommand<State> {
419425 ? ' (with lease)'
420426 : ''
421427 } ${ pushDetails } ${
422- status != null && status . state . behind > 0
423- ? `, overwriting ${ pluralize ( 'commit' , status . state . behind ) } ${
428+ status ?. upstream ?. state . behind
429+ ? `, overwriting ${ pluralize ( 'commit' , status . upstream . state . behind ) } ${
424430 status ?. upstream
425431 ? ` on ${ getRemoteNameFromBranchName ( status . upstream ?. name ) } `
426432 : ''
@@ -429,12 +435,12 @@ export class PushGitCommand extends QuickCommand<State> {
429435 } `,
430436 } ) ,
431437 ] ,
432- status ?. state . behind
438+ status ?. upstream ?. state . behind
433439 ? createDirectiveQuickPickItem ( Directive . Cancel , true , {
434440 label : `Cancel ${ this . title } ` ,
435441 detail : `Cannot push; ${ getReferenceLabel ( branch ) } is behind${
436442 status ?. upstream ? ` ${ getRemoteNameFromBranchName ( status . upstream ?. name ) } ` : ''
437- } by ${ pluralize ( 'commit' , status . state . behind ) } `,
443+ } by ${ pluralize ( 'commit' , status . upstream . state . behind ) } `,
438444 } )
439445 : undefined ,
440446 ) ;
0 commit comments