From 484807e82be790e4fe7cbe84f680aaccd662d433 Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Sat, 13 Nov 2010 00:42:01 +0100 Subject: [PATCH] Added one-tree constructor to DirCacheCheckout When DirCacheCheckout should be used to checkout only one tree (reset --hard, clone) then we had to use the standard constructor and specify null as value for head. This change adds explicit constructors not taking HEAD and documents that. Bug: 330021 Signed-off-by: Christian Halstrick --- .../jgit/dircache/DirCacheCheckout.java | 52 ++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java index bc51aa55a2..d2629728e6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java @@ -144,8 +144,8 @@ public class DirCacheCheckout { } /** - * Constructs a DirCacheCeckout for fast-forwarding from one tree to - * another, merging it with the index + * Constructs a DirCacheCeckout for merging and checking out two trees (HEAD + * and mergeCommitTree) and the index. * * @param repo * the repository in which we do the checkout @@ -169,6 +169,48 @@ public class DirCacheCheckout { this.workingTree = workingTree; } + /** + * Constructs a DirCacheCeckout for merging and checking out two trees (HEAD + * and mergeCommitTree) and the index. As iterator over the working tree + * this constructor creates a standard {@link FileTreeIterator} + * + * @param repo + * the repository in which we do the checkout + * @param headCommitTree + * the id of the tree of the head commit + * @param dc + * the (already locked) Dircache for this repo + * @param mergeCommitTree + * the id of the tree of the + * @throws IOException + */ + public DirCacheCheckout(Repository repo, ObjectId headCommitTree, + DirCache dc, ObjectId mergeCommitTree) throws IOException { + this(repo, headCommitTree, dc, mergeCommitTree, new FileTreeIterator( + repo.getWorkTree(), repo.getFS(), + WorkingTreeOptions.createDefaultInstance())); + } + + /** + * Constructs a DirCacheCeckout for checking out one tree, merging with the + * index. + * + * @param repo + * the repository in which we do the checkout + * @param dc + * the (already locked) Dircache for this repo + * @param mergeCommitTree + * the id of the tree we want to fast-forward to + * @param workingTree + * an iterator over the repositories Working Tree + * @throws IOException + */ + public DirCacheCheckout(Repository repo, DirCache dc, + ObjectId mergeCommitTree, WorkingTreeIterator workingTree) + throws IOException { + this(repo, null, dc, mergeCommitTree, workingTree); + } + /** * Constructs a DirCacheCeckout for checking out one tree, merging with the * index. As iterator over the working tree this constructor creates a @@ -176,17 +218,15 @@ public class DirCacheCheckout { * * @param repo * the repository in which we do the checkout - * @param headCommitTree - * the id of the tree of the head commit * @param dc * the (already locked) Dircache for this repo * @param mergeCommitTree * the id of the tree of the * @throws IOException */ - public DirCacheCheckout(Repository repo, ObjectId headCommitTree, DirCache dc, + public DirCacheCheckout(Repository repo, DirCache dc, ObjectId mergeCommitTree) throws IOException { - this(repo, headCommitTree, dc, mergeCommitTree, new FileTreeIterator( + this(repo, null, dc, mergeCommitTree, new FileTreeIterator( repo.getWorkTree(), repo.getFS(), WorkingTreeOptions.createDefaultInstance())); } -- 2.39.5