private @NotNull Pair<Integer, Set<Commit>> getNewCommitsAndSavedGreenIndex(@NotNull List<? extends Commit> savedLog,
                                                                              @NotNull Collection<? extends CommitId> previousRefs,
                                                                              @NotNull List<? extends Commit> firstBlock,
                                                                              @NotNull Collection<? extends CommitId> newRefs) {
    Set<CommitId> allUnresolvedLinkedHashes = new HashSet<>(newRefs);
    allUnresolvedLinkedHashes.removeAll(previousRefs);
    // at this moment allUnresolvedLinkedHashes contains only NEW refs
    for (Commit commit : firstBlock) {
      allUnresolvedLinkedHashes.add(commit.getId());
      allUnresolvedLinkedHashes.addAll(commit.getParents());
    }
    for (Commit commit : firstBlock) {
      if (!commit.getParents().isEmpty()) {
        allUnresolvedLinkedHashes.remove(commit.getId());
      }
    }
    int saveGreenIndex = getFirstUnTrackedIndex(savedLog, allUnresolvedLinkedHashes);

    return new Pair<>(saveGreenIndex, getAllNewCommits(savedLog.subList(0, saveGreenIndex), firstBlock));
  }
private @NotNull Pair<Integer, Set<Commit>> getNewCommitsAndSavedGreenIndex(@NotNull List<? extends Commit> savedLog,
                                                                              @NotNull Collection<? extends CommitId> previousRefs,
                                                                              @NotNull List<? extends Commit> firstBlock,
                                                                              @NotNull Collection<? extends CommitId> newRefs)