@@ -849,6 +849,42 @@ def meets_required_version?
849
849
( self . current_command_version <=> self . required_command_version ) >= 0
850
850
end
851
851
852
+ def command ( cmd , opts = [ ] , chdir = true , redirect = '' , &block )
853
+ global_opts = [ ]
854
+ global_opts << "--git-dir=#{ @git_dir } " if !@git_dir . nil?
855
+ global_opts << "--work-tree=#{ @git_work_dir } " if !@git_work_dir . nil?
856
+
857
+ opts = [ opts ] . flatten . map { |s | escape ( s ) } . join ( ' ' )
858
+
859
+ global_opts = global_opts . flatten . map { |s | escape ( s ) } . join ( ' ' )
860
+
861
+ git_cmd = "#{ Git ::Base . config . binary_path } #{ global_opts } #{ cmd } #{ opts } #{ redirect } 2>&1"
862
+
863
+ output = nil
864
+
865
+ command_thread = nil ;
866
+
867
+ exitstatus = nil
868
+
869
+ with_custom_env_variables do
870
+ command_thread = Thread . new do
871
+ output = run_command ( git_cmd , &block )
872
+ exitstatus = $?. exitstatus
873
+ end
874
+ command_thread . join
875
+ end
876
+
877
+ if @logger
878
+ @logger . info ( git_cmd )
879
+ @logger . debug ( output )
880
+ end
881
+
882
+ if exitstatus > 1 || ( exitstatus == 1 && output != '' )
883
+ raise Git ::GitExecuteError . new ( git_cmd + ':' + output . to_s )
884
+ end
885
+
886
+ return output
887
+ end
852
888
853
889
private
854
890
@@ -903,43 +939,6 @@ def with_custom_env_variables(&block)
903
939
restore_git_system_env_variables ( )
904
940
end
905
941
906
- def command ( cmd , opts = [ ] , chdir = true , redirect = '' , &block )
907
- global_opts = [ ]
908
- global_opts << "--git-dir=#{ @git_dir } " if !@git_dir . nil?
909
- global_opts << "--work-tree=#{ @git_work_dir } " if !@git_work_dir . nil?
910
-
911
- opts = [ opts ] . flatten . map { |s | escape ( s ) } . join ( ' ' )
912
-
913
- global_opts = global_opts . flatten . map { |s | escape ( s ) } . join ( ' ' )
914
-
915
- git_cmd = "#{ Git ::Base . config . binary_path } #{ global_opts } #{ cmd } #{ opts } #{ redirect } 2>&1"
916
-
917
- output = nil
918
-
919
- command_thread = nil ;
920
-
921
- exitstatus = nil
922
-
923
- with_custom_env_variables do
924
- command_thread = Thread . new do
925
- output = run_command ( git_cmd , &block )
926
- exitstatus = $?. exitstatus
927
- end
928
- command_thread . join
929
- end
930
-
931
- if @logger
932
- @logger . info ( git_cmd )
933
- @logger . debug ( output )
934
- end
935
-
936
- if exitstatus > 1 || ( exitstatus == 1 && output != '' )
937
- raise Git ::GitExecuteError . new ( git_cmd + ':' + output . to_s )
938
- end
939
-
940
- return output
941
- end
942
-
943
942
# Takes the diff command line output (as Array) and parse it into a Hash
944
943
#
945
944
# @param [String] diff_command the diff commadn to be used
0 commit comments