Browse Source

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 <spearce@spearce.org>
stable-0.12
Shawn O. Pearce 14 years ago
parent
commit
a0ead25a09
  1. 8
      org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java

8
org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java

@ -78,7 +78,7 @@ public class PushCommand extends GitCommand<Iterable<PushResult>> {
private String remote = Constants.DEFAULT_REMOTE_NAME; private String remote = Constants.DEFAULT_REMOTE_NAME;
private List<RefSpec> refSpecs; private final List<RefSpec> refSpecs;
private ProgressMonitor monitor = NullProgressMonitor.INSTANCE; private ProgressMonitor monitor = NullProgressMonitor.INSTANCE;
@ -124,10 +124,8 @@ public class PushCommand extends GitCommand<Iterable<PushResult>> {
try { try {
if (force) { if (force) {
final List<RefSpec> orig = new ArrayList<RefSpec>(refSpecs); for (int i = 0; i < refSpecs.size(); i++)
refSpecs.clear(); refSpecs.set(i, refSpecs.get(i).setForceUpdate(true));
for (final RefSpec spec : orig)
refSpecs.add(spec.setForceUpdate(true));
} }
final List<Transport> transports; final List<Transport> transports;

Loading…
Cancel
Save