@@ -151,9 +151,12 @@ private string FindCommitIdIfPushed(IGitUICommands commands, string head, int he
151
151
152
152
private string FindCommitId ( IGitUICommands commands , string head , int headOffset )
153
153
{
154
- string commitId = RunGitCommand ( commands , $ "rev-parse { head } ~{ headOffset } ") . Trim ( ) ;
155
- if ( ! String . IsNullOrWhiteSpace ( commitId ) && ! commitId . Contains ( " " ) )
156
- return commitId ;
154
+ if ( TryRunGitCommand ( commands , $ "rev-parse { head } ~{ headOffset } ", out string commitId ) )
155
+ {
156
+ commitId = commitId . Trim ( ) ;
157
+ if ( ! String . IsNullOrWhiteSpace ( commitId ) && ! commitId . Contains ( " " ) )
158
+ return commitId ;
159
+ }
157
160
158
161
return null ;
159
162
}
@@ -164,10 +167,7 @@ private bool IsCommitPushed(IGitUICommands commands, string head, int headOffset
164
167
if ( String . IsNullOrEmpty ( commitId ) )
165
168
return true ;
166
169
167
-
168
-
169
- string branches = RunGitCommand ( commands , $ "branch -r --contains { commitId } ") ;
170
- if ( String . IsNullOrWhiteSpace ( branches ) )
170
+ if ( ! TryRunGitCommand ( commands , $ "branch -r --contains { commitId } ", out string branches ) || String . IsNullOrWhiteSpace ( branches ) )
171
171
return false ;
172
172
173
173
if ( settings . RemoteNamesToCheck . Count > 0 )
@@ -214,17 +214,21 @@ private int BinarySearch(int start, int end, Func<int, int> predicate)
214
214
}
215
215
}
216
216
217
- private string RunGitCommand ( IGitUICommands commands , string arguments )
217
+ private bool TryRunGitCommand ( IGitUICommands commands , string arguments , out string output )
218
218
{
219
219
using ( IProcess process = commands . GitModule . GitCommandRunner . RunDetached ( arguments , redirectOutput : true ) )
220
220
{
221
221
process . WaitForExit ( ) ;
222
222
223
223
string error = process . StandardError . ReadToEnd ( ) ;
224
224
if ( ! String . IsNullOrEmpty ( error ) )
225
- return error ;
225
+ {
226
+ output = error ;
227
+ return false ;
228
+ }
226
229
227
- return process . StandardOutput . ReadToEnd ( ) ;
230
+ output = process . StandardOutput . ReadToEnd ( ) ;
231
+ return false ;
228
232
}
229
233
}
230
234
}
0 commit comments