aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse
diff options
context:
space:
mode:
authorThomas Wolf <twolf@apache.org>2022-09-18 19:24:58 +0200
committerThomas Wolf <twolf@apache.org>2022-09-18 19:43:40 +0200
commitf71fcbf36b9f9e21f8b796a0b2ea8226818e4780 (patch)
treef240534e5c0b0b05d5eb6d3fa962af327e43baa3 /org.eclipse.jgit/src/org/eclipse
parent4f4204914c6c996c4ffd81a26b8d9b0898523cdb (diff)
downloadjgit-f71fcbf36b9f9e21f8b796a0b2ea8226818e4780.tar.gz
jgit-f71fcbf36b9f9e21f8b796a0b2ea8226818e4780.zip
CloneCommand: set HEAD also when not checking out
CloneCommand, when setNoCheckout(true) was set, did not set HEAD. With C git, "git clone --no-checkout" does. Change-Id: Ief3df7e904ce90829a6345a6c3e9ee6a68486ab0 Signed-off-by: Thomas Wolf <twolf@apache.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java20
1 files changed, 9 insertions, 11 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
index 87c95ec830..107b00e274 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
@@ -216,16 +216,14 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
// ignore - the VM is already shutting down
}
}
- if (!noCheckout) {
- try {
- checkout(repository, fetchResult);
- } catch (IOException ioe) {
- repository.close();
- throw new JGitInternalException(ioe.getMessage(), ioe);
- } catch (GitAPIException | RuntimeException e) {
- repository.close();
- throw e;
- }
+ try {
+ checkout(repository, fetchResult);
+ } catch (IOException ioe) {
+ repository.close();
+ throw new JGitInternalException(ioe.getMessage(), ioe);
+ } catch (GitAPIException | RuntimeException e) {
+ repository.close();
+ throw e;
}
return new Git(repository, true);
}
@@ -393,7 +391,7 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
u.setNewObjectId(commit.getId());
u.forceUpdate();
- if (!bare) {
+ if (!bare && !noCheckout) {
DirCache dc = clonedRepo.lockDirCache();
DirCacheCheckout co = new DirCacheCheckout(clonedRepo, dc,
commit.getTree());