[git] Better logging in parsing the output of 'git remote show'.

This commit is contained in:
Kirill Likhodedov
2012-11-26 13:53:38 +04:00
parent 001c2c68cc
commit 8c6ee92ae9
@@ -246,7 +246,7 @@ public final class GitDeprecatedRemote {
public static GitDeprecatedRemote parseRemoteInternal(String name, String output) {
StringScanner in = new StringScanner(output);
if (!in.tryConsume("* ")) {
throw new IllegalStateException("Unexpected format for 'git remote show'");
throw new IllegalStateException(unexpectedFormat(name, output));
}
String nameLine = in.line();
if (!nameLine.endsWith(name)) {
@@ -268,11 +268,15 @@ public final class GitDeprecatedRemote {
}
}
else {
throw new IllegalStateException("Unexpected format for 'git remote show':\n" + output);
throw new IllegalStateException(unexpectedFormat(name, output));
}
return new GitDeprecatedRemote(name, fetch, push);
}
private static String unexpectedFormat(String remoteName, String output) {
return String.format("Unexpected format for 'git remote show'. Remote: %s, output:%n%s", remoteName, output);
}
/**
* Get information about remote stored in locally (remote end is not queried about branches)