@@ -37,19 +37,6 @@ public enum EditorType
3737 public bool RaiseError { get ; set ; } = true ;
3838 public Models . ICommandLog Log { get ; set ; } = null ;
3939
40- public void Exec ( )
41- {
42- try
43- {
44- var start = CreateGitStartInfo ( false ) ;
45- Process . Start ( start ) ;
46- }
47- catch ( Exception ex )
48- {
49- App . RaiseException ( Context , ex . Message ) ;
50- }
51- }
52-
5340 public async Task < bool > ExecAsync ( )
5441 {
5542 Log ? . AppendLine ( $ "$ git { Args } \n ") ;
@@ -127,6 +114,28 @@ public async Task<bool> ExecAsync()
127114 return true ;
128115 }
129116
117+ protected Result ReadToEnd ( )
118+ {
119+ using var proc = new Process ( ) { StartInfo = CreateGitStartInfo ( true ) } ;
120+
121+ try
122+ {
123+ proc . Start ( ) ;
124+ }
125+ catch ( Exception e )
126+ {
127+ return Result . Failed ( e . Message ) ;
128+ }
129+
130+ var rs = new Result ( ) { IsSuccess = true } ;
131+ rs . StdOut = proc . StandardOutput . ReadToEnd ( ) ;
132+ rs . StdErr = proc . StandardError . ReadToEnd ( ) ;
133+ proc . WaitForExit ( ) ;
134+
135+ rs . IsSuccess = proc . ExitCode == 0 ;
136+ return rs ;
137+ }
138+
130139 protected async Task < Result > ReadToEndAsync ( )
131140 {
132141 using var proc = new Process ( ) { StartInfo = CreateGitStartInfo ( true ) } ;
@@ -149,7 +158,7 @@ protected async Task<Result> ReadToEndAsync()
149158 return rs ;
150159 }
151160
152- private ProcessStartInfo CreateGitStartInfo ( bool redirect )
161+ protected ProcessStartInfo CreateGitStartInfo ( bool redirect )
153162 {
154163 var start = new ProcessStartInfo ( ) ;
155164 start . FileName = Native . OS . GitExecutable ;
@@ -167,8 +176,10 @@ private ProcessStartInfo CreateGitStartInfo(bool redirect)
167176 // Force using this app as SSH askpass program
168177 var selfExecFile = Process . GetCurrentProcess ( ) . MainModule ! . FileName ;
169178 start . Environment . Add ( "SSH_ASKPASS" , selfExecFile ) ; // Can not use parameter here, because it invoked by SSH with `exec`
170- start . Environment . Add ( "SSH_ASKPASS_REQUIRE" , "force " ) ;
179+ start . Environment . Add ( "SSH_ASKPASS_REQUIRE" , "prefer " ) ;
171180 start . Environment . Add ( "SOURCEGIT_LAUNCH_AS_ASKPASS" , "TRUE" ) ;
181+ if ( ! OperatingSystem . IsLinux ( ) )
182+ start . Environment . Add ( "DISPLAY" , "required" ) ;
172183
173184 // If an SSH private key was provided, sets the environment.
174185 if ( ! start . Environment . ContainsKey ( "GIT_SSH_COMMAND" ) && ! string . IsNullOrEmpty ( SSHKey ) )
0 commit comments