Patch Set 1:

Another (maybe better?) fix could be to return the "correct" ref (the one that is listed in .git/HEAD) when calling:
listRemoteOp.getRemoteRef(Constants.HEAD);

.git/HEAD contains ref: refs/heads/master, hence we already know it is 'master' and not some other ref. This would also improve the case where HEAD points to a different branch, like e.g. ref: refs/heads/R3_development. Currently, for this case we might still return the wrong ref, even with my patch.