From a0ead25a095f6fc62ebb0c913cc5249bf30c7249 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 14 Mar 2011 07:14:44 -0700 Subject: [PATCH] PushCommand: Set force-update in-place Rather than copying the entire list, just replace each element with the version that has setForceUpdate(true) invoked on it. Change-Id: I2eaa4466d497cb2408ce61dc62ca26e0c32fe841 Signed-off-by: Shawn O. Pearce --- .../src/org/eclipse/jgit/api/PushCommand.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 e8175d099..3ceeec42b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java @@ -78,7 +78,7 @@ public class PushCommand extends GitCommand> { private String remote = Constants.DEFAULT_REMOTE_NAME; - private List refSpecs; + private final List refSpecs; private ProgressMonitor monitor = NullProgressMonitor.INSTANCE; @@ -124,10 +124,8 @@ public class PushCommand extends GitCommand> { try { if (force) { - final List orig = new ArrayList(refSpecs); - refSpecs.clear(); - for (final RefSpec spec : orig) - refSpecs.add(spec.setForceUpdate(true)); + for (int i = 0; i < refSpecs.size(); i++) + refSpecs.set(i, refSpecs.get(i).setForceUpdate(true)); } final List transports;