|
|
@@ -312,35 +312,27 @@ public class ResetCommand extends GitCommand<Ref> { |
|
|
|
} |
|
|
|
|
|
|
|
private void resetIndex(RevCommit commit) throws IOException { |
|
|
|
DirCache dc = null; |
|
|
|
DirCache dc = repo.lockDirCache(); |
|
|
|
try { |
|
|
|
dc = repo.lockDirCache(); |
|
|
|
dc.clear(); |
|
|
|
DirCacheBuilder dcb = dc.builder(); |
|
|
|
dcb.addTree(new byte[0], 0, repo.newObjectReader(), |
|
|
|
commit.getTree()); |
|
|
|
dcb.commit(); |
|
|
|
} catch (IOException e) { |
|
|
|
throw e; |
|
|
|
} finally { |
|
|
|
if (dc != null) |
|
|
|
dc.unlock(); |
|
|
|
dc.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void checkoutIndex(RevCommit commit) throws IOException { |
|
|
|
DirCache dc = null; |
|
|
|
DirCache dc = repo.lockDirCache(); |
|
|
|
try { |
|
|
|
dc = repo.lockDirCache(); |
|
|
|
DirCacheCheckout checkout = new DirCacheCheckout(repo, dc, |
|
|
|
commit.getTree()); |
|
|
|
checkout.setFailOnConflict(false); |
|
|
|
checkout.checkout(); |
|
|
|
} catch (IOException e) { |
|
|
|
throw e; |
|
|
|
} finally { |
|
|
|
if (dc != null) |
|
|
|
dc.unlock(); |
|
|
|
dc.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
|