boolean (@NotNull GitRepository repository, @NotNull GitLocalBranch localBranch, @Nullable Hash localBranchHash, @Nullable Hash localHashForRemoteBranch, boolean incoming) { if (!supportsIncomingOutgoing()) return false; if (localHashForRemoteBranch == null || Objects.equals(localBranchHash, localHashForRemoteBranch)) return false; //run git rev-list --count pushTargetForBranch_or_hash..localName for outgoing ( @{push} can be used only for equal branch names) //see git-push help -> simple push strategy //git rev-list --count localName..localName@{u} for incoming String branchName = localBranch.getName(); String from = incoming ? branchName : localHashForRemoteBranch.asString(); String to = incoming ? branchName + "@{u}" : branchName; String numberOfCommitsBetween = GitHistoryUtils.getNumberOfCommitsBetween(repository, from, to); if (numberOfCommitsBetween == null) { LOG.warn("Can't get outgoing info (git rev-list " + branchName + " failed)"); return false; } return !StringUtil.startsWithChar(numberOfCommitsBetween, '0'); }