@@ -293,11 +293,8 @@ test_expect_success '--set-upstream-to @{-1}' '
293293'
294294
295295test_expect_success ' status tracking origin/main shows only main' '
296- (
297- cd test &&
298- git checkout b4 &&
299- git status >../actual
300- ) &&
296+ git -C test checkout b4 &&
297+ git -C test status >actual &&
301298 cat >expect <<-EOF &&
302299 On branch b4
303300 Your branch is ahead of ${SQ}origin/main${SQ} by 2 commits.
@@ -309,11 +306,8 @@ test_expect_success 'status tracking origin/main shows only main' '
309306'
310307
311308test_expect_success ' status --no-ahead-behind tracking origin/main shows only main' '
312- (
313- cd test &&
314- git checkout b4 &&
315- git status --no-ahead-behind >../actual
316- ) &&
309+ git -C test checkout b4 &&
310+ git -C test status --no-ahead-behind >actual &&
317311 cat >expect <<-EOF &&
318312 On branch b4
319313 Your branch and ${SQ}origin/main${SQ} refer to different commits.
@@ -324,7 +318,7 @@ test_expect_success 'status --no-ahead-behind tracking origin/main shows only ma
324318 test_cmp expect actual
325319'
326320
327- test_expect_success ' status.compareBranches from upstream has no duplicates ' '
321+ test_expect_success ' status.compareBranches deduplicates when upstream and push are the same ' '
328322 test_config -C test status.compareBranches "@{upstream} @{push}" &&
329323 git -C test checkout main &&
330324 git -C test status >actual &&
@@ -337,18 +331,48 @@ test_expect_success 'status.compareBranches from upstream has no duplicates' '
337331 test_cmp expect actual
338332'
339333
340- test_expect_success ' status.compareBranches shows ahead of both upstream and push branch' '
334+ test_expect_success ' status.compareBranches with only upstream shows only upstream' '
335+ test_config -C test status.compareBranches "@{upstream}" &&
336+ git -C test checkout main &&
337+ git -C test status >actual &&
338+ cat >expect <<-EOF &&
339+ On branch main
340+ Your branch is up to date with ${SQ}origin/main${SQ}.
341+
342+ nothing to commit, working tree clean
343+ EOF
344+ test_cmp expect actual
345+ '
346+
347+ test_expect_success ' status.compareBranches with only push shows only push' '
341348 test_config -C test push.default current &&
342- test_config -C test status.compareBranches "@{upstream} @{ push}" &&
349+ test_config -C test status.compareBranches "@{push}" &&
343350 git -C test checkout -b feature2 origin/main &&
344351 git -C test push origin HEAD &&
345352 (cd test && advance work) &&
346353 git -C test status >actual &&
347354 cat >expect <<-EOF &&
348355 On branch feature2
356+ Your branch is ahead of ${SQ}origin/feature2${SQ} by 1 commit.
357+ (use "git push" to publish your local commits)
358+
359+ nothing to commit, working tree clean
360+ EOF
361+ test_cmp expect actual
362+ '
363+
364+ test_expect_success ' status.compareBranches shows ahead of both upstream and push branch' '
365+ test_config -C test push.default current &&
366+ test_config -C test status.compareBranches "@{upstream} @{push}" &&
367+ git -C test checkout -b feature3 origin/main &&
368+ git -C test push origin HEAD &&
369+ (cd test && advance work) &&
370+ git -C test status >actual &&
371+ cat >expect <<-EOF &&
372+ On branch feature3
349373 Your branch is ahead of ${SQ}origin/main${SQ} by 1 commit.
350374
351- Your branch is ahead of ${SQ}origin/feature2 ${SQ} by 1 commit.
375+ Your branch is ahead of ${SQ}origin/feature3 ${SQ} by 1 commit.
352376 (use "git push" to publish your local commits)
353377
354378 nothing to commit, working tree clean
@@ -359,11 +383,11 @@ test_expect_success 'status.compareBranches shows ahead of both upstream and pus
359383test_expect_success ' checkout with status.compareBranches shows both branches' '
360384 test_config -C test push.default current &&
361385 test_config -C test status.compareBranches "@{upstream} @{push}" &&
362- git -C test checkout feature2 >actual &&
386+ git -C test checkout feature3 >actual &&
363387 cat >expect <<-EOF &&
364388 Your branch is ahead of ${SQ}origin/main${SQ} by 1 commit.
365389
366- Your branch is ahead of ${SQ}origin/feature2 ${SQ} by 1 commit.
390+ Your branch is ahead of ${SQ}origin/feature3 ${SQ} by 1 commit.
367391 (use "git push" to publish your local commits)
368392 EOF
369393 test_cmp expect actual
@@ -469,21 +493,41 @@ test_expect_success 'status.compareBranches supports ordered upstream/push entri
469493 test_cmp expect actual
470494'
471495
496+ test_expect_success ' status.compareBranches deduplicates repeated specifiers' '
497+ test_config -C test push.default current &&
498+ test_config -C test remote.pushDefault origin &&
499+ test_config -C test status.compareBranches "@{push} @{upstream} @{push}" &&
500+ git -C test checkout -b feature7 upstream/main &&
501+ git -C test push origin &&
502+ (cd test && advance work) &&
503+ git -C test status >actual &&
504+ cat >expect <<-EOF &&
505+ On branch feature7
506+ Your branch is ahead of ${SQ}origin/feature7${SQ} by 1 commit.
507+ (use "git push" to publish your local commits)
508+
509+ Your branch is ahead of ${SQ}upstream/main${SQ} by 1 commit.
510+
511+ nothing to commit, working tree clean
512+ EOF
513+ test_cmp expect actual
514+ '
515+
472516test_expect_success ' status.compareBranches with diverged push branch' '
473517 test_config -C test push.default current &&
474518 test_config -C test remote.pushDefault origin &&
475519 test_config -C test status.compareBranches "@{upstream} @{push}" &&
476- git -C test checkout -b feature7 upstream/main &&
477- (cd test && advance work71 ) &&
520+ git -C test checkout -b feature8 upstream/main &&
521+ (cd test && advance work81 ) &&
478522 git -C test push origin &&
479523 git -C test reset --hard upstream/main &&
480- (cd test && advance work72 ) &&
524+ (cd test && advance work82 ) &&
481525 git -C test status >actual &&
482526 cat >expect <<-EOF &&
483- On branch feature7
527+ On branch feature8
484528 Your branch is ahead of ${SQ}upstream/main${SQ} by 1 commit.
485529
486- Your branch and ${SQ}origin/feature7 ${SQ} have diverged,
530+ Your branch and ${SQ}origin/feature8 ${SQ} have diverged,
487531 and have 1 and 1 different commits each, respectively.
488532
489533 nothing to commit, working tree clean
@@ -495,14 +539,14 @@ test_expect_success 'status.compareBranches shows up to date branches' '
495539 test_config -C test push.default current &&
496540 test_config -C test remote.pushDefault origin &&
497541 test_config -C test status.compareBranches "@{upstream} @{push}" &&
498- git -C test checkout -b feature8 upstream/main &&
542+ git -C test checkout -b feature9 upstream/main &&
499543 git -C test push origin &&
500544 git -C test status >actual &&
501545 cat >expect <<-EOF &&
502- On branch feature8
546+ On branch feature9
503547 Your branch is up to date with ${SQ}upstream/main${SQ}.
504548
505- Your branch is up to date with ${SQ}origin/feature8 ${SQ}.
549+ Your branch is up to date with ${SQ}origin/feature9 ${SQ}.
506550
507551 nothing to commit, working tree clean
508552 EOF
@@ -513,14 +557,14 @@ test_expect_success 'status --no-ahead-behind with status.compareBranches up to
513557 test_config -C test push.default current &&
514558 test_config -C test remote.pushDefault origin &&
515559 test_config -C test status.compareBranches "@{upstream} @{push}" &&
516- git -C test checkout feature8 >actual &&
560+ git -C test checkout feature9 >actual &&
517561 git -C test push origin &&
518562 git -C test status --no-ahead-behind >actual &&
519563 cat >expect <<-EOF &&
520- On branch feature8
564+ On branch feature9
521565 Your branch is up to date with ${SQ}upstream/main${SQ}.
522566
523- Your branch is up to date with ${SQ}origin/feature8 ${SQ}.
567+ Your branch is up to date with ${SQ}origin/feature9 ${SQ}.
524568
525569 nothing to commit, working tree clean
526570 EOF
@@ -531,11 +575,11 @@ test_expect_success 'checkout with status.compareBranches shows up to date' '
531575 test_config -C test push.default current &&
532576 test_config -C test remote.pushDefault origin &&
533577 test_config -C test status.compareBranches "@{upstream} @{push}" &&
534- git -C test checkout feature8 >actual &&
578+ git -C test checkout feature9 >actual &&
535579 cat >expect <<-EOF &&
536580 Your branch is up to date with ${SQ}upstream/main${SQ}.
537581
538- Your branch is up to date with ${SQ}origin/feature8 ${SQ}.
582+ Your branch is up to date with ${SQ}origin/feature9 ${SQ}.
539583 EOF
540584 test_cmp expect actual
541585'
@@ -547,31 +591,31 @@ test_expect_success 'status.compareBranches with upstream behind and push up to
547591 git -C test checkout -b ahead upstream/main &&
548592 (cd test && advance work) &&
549593 git -C test push upstream HEAD &&
550- git -C test checkout -b feature9 upstream/main &&
594+ git -C test checkout -b feature10 upstream/main &&
551595 git -C test push origin &&
552596 git -C test branch --set-upstream-to upstream/ahead &&
553597 git -C test status >actual &&
554598 cat >expect <<-EOF &&
555- On branch feature9
599+ On branch feature10
556600 Your branch is behind ${SQ}upstream/ahead${SQ} by 1 commit, and can be fast-forwarded.
557601 (use "git pull" to update your local branch)
558602
559- Your branch is up to date with ${SQ}origin/feature9 ${SQ}.
603+ Your branch is up to date with ${SQ}origin/feature10 ${SQ}.
560604
561605 nothing to commit, working tree clean
562606 EOF
563607 test_cmp expect actual
564608'
565609
566610test_expect_success ' status.compareBranches with remapped push refspec' '
567- test_config -C test remote.origin.push refs/heads/feature10 :refs/heads/remapped &&
611+ test_config -C test remote.origin.push refs/heads/feature11 :refs/heads/remapped &&
568612 test_config -C test status.compareBranches "@{upstream} @{push}" &&
569- git -C test checkout -b feature10 origin/main &&
613+ git -C test checkout -b feature11 origin/main &&
570614 git -C test push &&
571615 (cd test && advance work) &&
572616 git -C test status >actual &&
573617 cat >expect <<-EOF &&
574- On branch feature10
618+ On branch feature11
575619 Your branch is ahead of ${SQ}origin/main${SQ} by 1 commit.
576620
577621 Your branch is ahead of ${SQ}origin/remapped${SQ} by 1 commit.
@@ -584,14 +628,14 @@ test_expect_success 'status.compareBranches with remapped push refspec' '
584628
585629test_expect_success ' status.compareBranches with remapped push and upstream remote' '
586630 test_config -C test remote.pushDefault origin &&
587- test_config -C test remote.origin.push refs/heads/feature11 :refs/heads/remapped &&
631+ test_config -C test remote.origin.push refs/heads/feature12 :refs/heads/remapped &&
588632 test_config -C test status.compareBranches "@{upstream} @{push}" &&
589- git -C test checkout -b feature11 upstream/main &&
633+ git -C test checkout -b feature12 upstream/main &&
590634 git -C test push origin &&
591635 (cd test && advance work) &&
592636 git -C test status >actual &&
593637 cat >expect <<-EOF &&
594- On branch feature11
638+ On branch feature12
595639 Your branch is ahead of ${SQ}upstream/main${SQ} by 1 commit.
596640
597641 Your branch is ahead of ${SQ}origin/remapped${SQ} by 1 commit.
0 commit comments