@@ -833,14 +833,21 @@ def fetch(
833
833
if not allow_unsafe_options :
834
834
Git .check_unsafe_options (options = list (kwargs .keys ()), unsafe_options = self .unsafe_git_fetch_options )
835
835
836
- proc = self .repo .git .fetch (self , * args , as_process = True , with_stdout = False ,
836
+ proc = self .repo .git .fetch ("--" , self , * args , as_process = True , with_stdout = False ,
837
837
universal_newlines = True , v = True , ** kwargs )
838
838
res = self ._get_fetch_info_from_stderr (proc , progress )
839
839
if hasattr (self .repo .odb , 'update_cache' ):
840
840
self .repo .odb .update_cache ()
841
841
return res
842
842
843
- def pull (self , refspec = None , progress = None , ** kwargs ):
843
+ def pull (
844
+ self ,
845
+ refspec = None ,
846
+ progress = None ,
847
+ allow_unsafe_protocols = False ,
848
+ allow_unsafe_options = False ,
849
+ ** kwargs
850
+ ):
844
851
"""Pull changes from the given branch, being the same as a fetch followed
845
852
by a merge of branch with your local branch.
846
853
@@ -852,14 +859,28 @@ def pull(self, refspec=None, progress=None, **kwargs):
852
859
# No argument refspec, then ensure the repo's config has a fetch refspec.
853
860
self ._assert_refspec ()
854
861
kwargs = add_progress (kwargs , self .repo .git , progress )
855
- proc = self .repo .git .pull (self , refspec , with_stdout = False , as_process = True ,
862
+
863
+ refspec = Git ._unpack_args (refspec or [])
864
+ if not allow_unsafe_protocols :
865
+ for ref in refspec :
866
+ Git .check_unsafe_protocols (ref )
867
+ if not allow_unsafe_options :
868
+ Git .check_unsafe_options (options = list (kwargs .keys ()), unsafe_options = self .unsafe_git_pull_options )
869
+
870
+ proc = self .repo .git .pull ("--" , self , refspec , with_stdout = False , as_process = True ,
856
871
universal_newlines = True , v = True , ** kwargs )
857
872
res = self ._get_fetch_info_from_stderr (proc , progress )
858
873
if hasattr (self .repo .odb , 'update_cache' ):
859
874
self .repo .odb .update_cache ()
860
875
return res
861
876
862
- def push (self , refspec = None , progress = None , ** kwargs ):
877
+ def push (
878
+ self ,
879
+ refspec = None ,
880
+ progress = None ,
881
+ allow_unsafe_protocols = False ,
882
+ allow_unsafe_options = False ,
883
+ ** kwargs ):
863
884
"""Push changes from source branch in refspec to target branch in refspec.
864
885
865
886
:param refspec: see 'fetch' method
@@ -887,7 +908,15 @@ def push(self, refspec=None, progress=None, **kwargs):
887
908
If the operation fails completely, the length of the returned IterableList will
888
909
be null."""
889
910
kwargs = add_progress (kwargs , self .repo .git , progress )
890
- proc = self .repo .git .push (self , refspec , porcelain = True , as_process = True ,
911
+
912
+ refspec = Git ._unpack_args (refspec or [])
913
+ if not allow_unsafe_protocols :
914
+ for ref in refspec :
915
+ Git .check_unsafe_protocols (ref )
916
+ if not allow_unsafe_options :
917
+ Git .check_unsafe_options (options = list (kwargs .keys ()), unsafe_options = self .unsafe_git_push_options )
918
+
919
+ proc = self .repo .git .push ("--" , self , refspec , porcelain = True , as_process = True ,
891
920
universal_newlines = True , ** kwargs )
892
921
return self ._get_push_info (proc , progress )
893
922
0 commit comments