@@ -737,14 +737,50 @@ test_expect_success 'rename a remote' '
737
737
git clone one four &&
738
738
(
739
739
cd four &&
740
+ test_config_global remote.pushDefault origin &&
740
741
git config branch.master.pushRemote origin &&
741
742
git remote rename origin upstream &&
742
743
test -z "$(git for-each-ref refs/remotes/origin)" &&
743
744
test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" &&
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
+ git clone one four.2 &&
765
+ (
766
+ cd four.2 &&
767
+ test_config_global remote.pushDefault other &&
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
+ git clone one four.3 &&
777
+ (
778
+ cd four.3 &&
779
+ test_config_global remote.pushDefault origin &&
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
@@ -790,11 +826,47 @@ test_expect_success 'remove a remote' '
790
826
git clone one four.five &&
791
827
(
792
828
cd four.five &&
829
+ test_config_global remote.pushDefault origin &&
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
+ git clone one four.five.2 &&
851
+ (
852
+ cd four.five.2 &&
853
+ test_config_global remote.pushDefault other &&
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
+ git clone one four.five.3 &&
863
+ (
864
+ cd four.five.3 &&
865
+ test_config_global remote.pushDefault origin &&
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