Browse Source

CLI clone command should support --no-checkout

doCheckout() is called only if --no-checkout option is not set.

Bug: 428917
Change-Id: I350bef446dd7a37613b9506aae99679569bd36e1
Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-3.4
Kaloyan Raev 11 years ago committed by Matthias Sohn
parent
commit
44812c02e8
  1. 1
      org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
  2. 10
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java

1
org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties

@ -293,6 +293,7 @@ usage_mergeRef=Ref to be merged
usage_mergeStrategy=Use the given merge strategy. Can be supplied more than once to specify them in the order they should be tried. If there is no -s option, the recursive strategy is used. Currently the following strategies are supported: ours, theirs, simple-two-way-in-core, resolve, recursive usage_mergeStrategy=Use the given merge strategy. Can be supplied more than once to specify them in the order they should be tried. If there is no -s option, the recursive strategy is used. Currently the following strategies are supported: ours, theirs, simple-two-way-in-core, resolve, recursive
usage_moveRenameABranch=move/rename a branch usage_moveRenameABranch=move/rename a branch
usage_nameStatus=show only name and status of files usage_nameStatus=show only name and status of files
usage_noCheckoutAfterClone=no checkout of HEAD is performed after the clone is complete
usage_noCommit=Don't commit after a successful merge usage_noCommit=Don't commit after a successful merge
usage_noPrefix=do not show any source or destination prefix usage_noPrefix=do not show any source or destination prefix
usage_noRenames=disable rename detection usage_noRenames=disable rename detection

10
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java

@ -79,6 +79,9 @@ class Clone extends AbstractFetchCommand {
@Option(name = "--branch", aliases = { "-b" }, metaVar = "metaVar_branchName", usage = "usage_checkoutBranchAfterClone") @Option(name = "--branch", aliases = { "-b" }, metaVar = "metaVar_branchName", usage = "usage_checkoutBranchAfterClone")
private String branch; private String branch;
@Option(name = "--no-checkout", aliases = { "-n" }, usage = "usage_noCheckoutAfterClone")
private boolean noCheckout;
@Argument(index = 0, required = true, metaVar = "metaVar_uriish") @Argument(index = 0, required = true, metaVar = "metaVar_uriish")
private String sourceUri; private String sourceUri;
@ -122,17 +125,20 @@ class Clone extends AbstractFetchCommand {
saveRemote(uri); saveRemote(uri);
final FetchResult r = runFetch(); final FetchResult r = runFetch();
if (!noCheckout) {
final Ref checkoutRef; final Ref checkoutRef;
if (branch == null) if (branch == null)
checkoutRef = guessHEAD(r); checkoutRef = guessHEAD(r);
else { else {
checkoutRef = r.getAdvertisedRef(Constants.R_HEADS + branch); checkoutRef = r.getAdvertisedRef(Constants.R_HEADS + branch);
if (checkoutRef == null) if (checkoutRef == null)
throw die(MessageFormat.format(CLIText.get().noSuchRemoteRef, throw die(MessageFormat.format(
branch)); CLIText.get().noSuchRemoteRef, branch));
} }
doCheckout(checkoutRef); doCheckout(checkoutRef);
} }
}
private void saveRemote(final URIish uri) throws URISyntaxException, private void saveRemote(final URIish uri) throws URISyntaxException,
IOException { IOException {

Loading…
Cancel
Save