@@ -734,6 +734,7 @@ test_expect_success 'reject adding remote with an invalid name' '
734
734
# the last two ones check if the config is updated.
735
735
736
736
test_expect_success ' rename a remote' '
737
+ test_config_global remote.pushDefault origin &&
737
738
git clone one four &&
738
739
(
739
740
cd four &&
@@ -744,7 +745,42 @@ test_expect_success 'rename a remote' '
744
745
test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" &&
745
746
test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" &&
746
747
test "$(git config branch.master.remote)" = "upstream" &&
747
- test "$(git config branch.master.pushRemote)" = "upstream"
748
+ test "$(git config branch.master.pushRemote)" = "upstream" &&
749
+ test "$(git config --global remote.pushDefault)" = "origin"
750
+ )
751
+ '
752
+
753
+ test_expect_success ' rename a remote renames repo remote.pushDefault' '
754
+ git clone one four.1 &&
755
+ (
756
+ cd four.1 &&
757
+ git config remote.pushDefault origin &&
758
+ git remote rename origin upstream &&
759
+ test "$(git config --local remote.pushDefault)" = "upstream"
760
+ )
761
+ '
762
+
763
+ test_expect_success ' rename a remote renames repo remote.pushDefault but ignores global' '
764
+ test_config_global remote.pushDefault other &&
765
+ git clone one four.2 &&
766
+ (
767
+ cd four.2 &&
768
+ git config remote.pushDefault origin &&
769
+ git remote rename origin upstream &&
770
+ test "$(git config --global remote.pushDefault)" = "other" &&
771
+ test "$(git config --local remote.pushDefault)" = "upstream"
772
+ )
773
+ '
774
+
775
+ test_expect_success ' rename a remote renames repo remote.pushDefault but keeps global' '
776
+ test_config_global remote.pushDefault origin &&
777
+ git clone one four.3 &&
778
+ (
779
+ cd four.3 &&
780
+ git config remote.pushDefault origin &&
781
+ git remote rename origin upstream &&
782
+ test "$(git config --global remote.pushDefault)" = "origin" &&
783
+ test "$(git config --local remote.pushDefault)" = "upstream"
748
784
)
749
785
'
750
786
@@ -787,14 +823,50 @@ test_expect_success 'rename succeeds with existing remote.<target>.prune' '
787
823
'
788
824
789
825
test_expect_success ' remove a remote' '
826
+ test_config_global remote.pushDefault origin &&
790
827
git clone one four.five &&
791
828
(
792
829
cd four.five &&
793
830
git config branch.master.pushRemote origin &&
794
831
git remote remove origin &&
795
832
test -z "$(git for-each-ref refs/remotes/origin)" &&
796
833
test_must_fail git config branch.master.remote &&
797
- test_must_fail git config branch.master.pushRemote
834
+ test_must_fail git config branch.master.pushRemote &&
835
+ test "$(git config --global remote.pushDefault)" = "origin"
836
+ )
837
+ '
838
+
839
+ test_expect_success ' remove a remote removes repo remote.pushDefault' '
840
+ git clone one four.five.1 &&
841
+ (
842
+ cd four.five.1 &&
843
+ git config remote.pushDefault origin &&
844
+ git remote remove origin &&
845
+ test_must_fail git config --local remote.pushDefault
846
+ )
847
+ '
848
+
849
+ test_expect_success ' remove a remote removes repo remote.pushDefault but ignores global' '
850
+ test_config_global remote.pushDefault other &&
851
+ git clone one four.five.2 &&
852
+ (
853
+ cd four.five.2 &&
854
+ git config remote.pushDefault origin &&
855
+ git remote remove origin &&
856
+ test "$(git config --global remote.pushDefault)" = "other" &&
857
+ test_must_fail git config --local remote.pushDefault
858
+ )
859
+ '
860
+
861
+ test_expect_success ' remove a remote removes repo remote.pushDefault but keeps global' '
862
+ test_config_global remote.pushDefault origin &&
863
+ git clone one four.five.3 &&
864
+ (
865
+ cd four.five.3 &&
866
+ git config remote.pushDefault origin &&
867
+ git remote remove origin &&
868
+ test "$(git config --global remote.pushDefault)" = "origin" &&
869
+ test_must_fail git config --local remote.pushDefault
798
870
)
799
871
'
800
872
0 commit comments