|
|
@ -208,7 +208,7 @@ public class CheckoutCommand extends GitCommand<Ref> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (createBranch) { |
|
|
|
if (createBranch) { |
|
|
|
Git git = new Git(repo); |
|
|
|
try (Git git = new Git(repo)) { |
|
|
|
CreateBranchCommand command = git.branchCreate(); |
|
|
|
CreateBranchCommand command = git.branchCreate(); |
|
|
|
command.setName(name); |
|
|
|
command.setName(name); |
|
|
|
if (startCommit != null) |
|
|
|
if (startCommit != null) |
|
|
@ -219,6 +219,7 @@ public class CheckoutCommand extends GitCommand<Ref> { |
|
|
|
command.setUpstreamMode(upstreamMode); |
|
|
|
command.setUpstreamMode(upstreamMode); |
|
|
|
command.call(); |
|
|
|
command.call(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Ref headRef = repo.getRef(Constants.HEAD); |
|
|
|
Ref headRef = repo.getRef(Constants.HEAD); |
|
|
|
String shortHeadRef = getShortBranchName(headRef); |
|
|
|
String shortHeadRef = getShortBranchName(headRef); |
|
|
@ -243,11 +244,14 @@ public class CheckoutCommand extends GitCommand<Ref> { |
|
|
|
JGitText.get().refNotResolved, name)); |
|
|
|
JGitText.get().refNotResolved, name)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RevWalk revWalk = new RevWalk(repo); |
|
|
|
RevCommit headCommit = null; |
|
|
|
|
|
|
|
RevCommit newCommit = null; |
|
|
|
|
|
|
|
try (RevWalk revWalk = new RevWalk(repo)) { |
|
|
|
AnyObjectId headId = headRef.getObjectId(); |
|
|
|
AnyObjectId headId = headRef.getObjectId(); |
|
|
|
RevCommit headCommit = headId == null ? null : revWalk |
|
|
|
headCommit = headId == null ? null |
|
|
|
.parseCommit(headId); |
|
|
|
: revWalk.parseCommit(headId); |
|
|
|
RevCommit newCommit = revWalk.parseCommit(branch); |
|
|
|
newCommit = revWalk.parseCommit(branch); |
|
|
|
|
|
|
|
} |
|
|
|
RevTree headTree = headCommit == null ? null : headCommit.getTree(); |
|
|
|
RevTree headTree = headCommit == null ? null : headCommit.getTree(); |
|
|
|
DirCacheCheckout dco; |
|
|
|
DirCacheCheckout dco; |
|
|
|
DirCache dc = repo.lockDirCache(); |
|
|
|
DirCache dc = repo.lockDirCache(); |
|
|
@ -376,26 +380,20 @@ public class CheckoutCommand extends GitCommand<Ref> { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected CheckoutCommand checkoutPaths() throws IOException, |
|
|
|
protected CheckoutCommand checkoutPaths() throws IOException, |
|
|
|
RefNotFoundException { |
|
|
|
RefNotFoundException { |
|
|
|
RevWalk revWalk = new RevWalk(repo); |
|
|
|
|
|
|
|
DirCache dc = repo.lockDirCache(); |
|
|
|
DirCache dc = repo.lockDirCache(); |
|
|
|
try { |
|
|
|
try (RevWalk revWalk = new RevWalk(repo); |
|
|
|
TreeWalk treeWalk = new TreeWalk(revWalk.getObjectReader()); |
|
|
|
TreeWalk treeWalk = new TreeWalk(revWalk.getObjectReader())) { |
|
|
|
treeWalk.setRecursive(true); |
|
|
|
treeWalk.setRecursive(true); |
|
|
|
if (!checkoutAllPaths) |
|
|
|
if (!checkoutAllPaths) |
|
|
|
treeWalk.setFilter(PathFilterGroup.createFromStrings(paths)); |
|
|
|
treeWalk.setFilter(PathFilterGroup.createFromStrings(paths)); |
|
|
|
try { |
|
|
|
|
|
|
|
if (isCheckoutIndex()) |
|
|
|
if (isCheckoutIndex()) |
|
|
|
checkoutPathsFromIndex(treeWalk, dc); |
|
|
|
checkoutPathsFromIndex(treeWalk, dc); |
|
|
|
else { |
|
|
|
else { |
|
|
|
RevCommit commit = revWalk.parseCommit(getStartPointObjectId()); |
|
|
|
RevCommit commit = revWalk.parseCommit(getStartPointObjectId()); |
|
|
|
checkoutPathsFromCommit(treeWalk, dc, commit); |
|
|
|
checkoutPathsFromCommit(treeWalk, dc, commit); |
|
|
|
} |
|
|
|
} |
|
|
|
} finally { |
|
|
|
|
|
|
|
treeWalk.release(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
dc.unlock(); |
|
|
|
dc.unlock(); |
|
|
|
revWalk.release(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|