From b1d703603e00943451a8ed6164558ffc80f9d825 Mon Sep 17 00:00:00 2001
From: Georg Seibt <seibt@fim.uni-passau.de>
Date: Fri, 15 Apr 2016 22:35:11 +0200
Subject: [PATCH] remove contains check in Repository::checkout (problematic in
 conjunction with the copy method and the git call will fail anyway if the
 commit id is invalid), copy commits in Repository::copy

---
 .../fim/seibt/gitwrapper/repo/Repository.java      | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java b/src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
index 5bf2620..798ecda 100644
--- a/src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
+++ b/src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
@@ -66,12 +66,6 @@ public class Repository {
      * @see <a href=https://git-scm.com/docs/git-checkout>git checkout</a>
      */
     public boolean checkout(Commit c) {
-
-        if (!commits.containsValue(c)) {
-            LOG.warning(() -> String.format("Checkout failed. %s is not part of %s.", c, this));
-            return false;
-        }
-
         Optional<ExecRes> checkout = git.exec(dir, "checkout", c.getId());
         Function<ExecRes, Boolean> toBoolean = res -> {
             boolean failed = git.failed(res);
@@ -240,7 +234,13 @@ public class Repository {
             return Optional.empty();
         }
 
-        return Optional.of(new Repository(git, url, destination));
+        Repository repo = new Repository(git, url, destination);
+
+        for (Map.Entry<String, Commit> entry : commits.entrySet()) {
+            repo.getCommitUnchecked(entry.getValue().getId());
+        }
+
+        return Optional.of(repo);
     }
 
     /**
-- 
GitLab