From c3c4398b649acafc5a774a6c58bc846e54fb641b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 14 Mar 2011 07:20:02 -0700 Subject: [PATCH] PushCommand: Default to pushing HEAD If no RefSpec was specified, push the branch that is currently checked out as HEAD. Change-Id: I6f13ef6346188698a14e000fc590850afbc34b21 Signed-off-by: Shawn O. Pearce --- org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java index 3ceeec42b..eefe401d1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java @@ -58,6 +58,7 @@ import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.ProgressMonitor; +import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.transport.CredentialsProvider; import org.eclipse.jgit.transport.PushResult; @@ -123,6 +124,12 @@ public Iterable call() throws JGitInternalException, ArrayList pushResults = new ArrayList(3); try { + if (refSpecs.isEmpty()) { + Ref head = repo.getRef(Constants.HEAD); + if (head != null && head.isSymbolic()) + refSpecs.add(new RefSpec(head.getLeaf().getName())); + } + if (force) { for (int i = 0; i < refSpecs.size(); i++) refSpecs.set(i, refSpecs.get(i).setForceUpdate(true));