]> source.dussan.org Git - jgit.git/commitdiff
PushCommand: Set force-update in-place 00/2700/2
authorShawn O. Pearce <spearce@spearce.org>
Mon, 14 Mar 2011 14:14:44 +0000 (07:14 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 14 Mar 2011 15:02:35 +0000 (08:02 -0700)
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 <spearce@spearce.org>
org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java

index e8175d0997568c50160d9759b42adb674a667af2..3ceeec42b089e2e118a0cc797e1c91829b14b2b9 100644 (file)
@@ -78,7 +78,7 @@ public class PushCommand extends GitCommand<Iterable<PushResult>> {
 
        private String remote = Constants.DEFAULT_REMOTE_NAME;
 
-       private List<RefSpec> refSpecs;
+       private final List<RefSpec> refSpecs;
 
        private ProgressMonitor monitor = NullProgressMonitor.INSTANCE;
 
@@ -124,10 +124,8 @@ public class PushCommand extends GitCommand<Iterable<PushResult>> {
 
                try {
                        if (force) {
-                               final List<RefSpec> orig = new ArrayList<RefSpec>(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<Transport> transports;