Source:
<code>public MergeCommand merge() { return new MergeCommand() { public ObjectId rev; public String comment; public String strategy; public String fastForwardMode; public boolean squash; public boolean commit = true; public MergeCommand setRevisionToMerge(ObjectId rev) { this.rev = rev; return this; } public MergeCommand setStrategy(MergeCommand.Strategy strategy) { this.strategy = strategy.toString(); return this; } public MergeCommand setGitPluginFastForwardMode(MergeCommand.GitPluginFastForwardMode fastForwardMode) { this.fastForwardMode = fastForwardMode.toString(); return this; } public MergeCommand setSquash(boolean squash) { this.squash = squash; return this; } public MergeCommand setMessage(String comment) { this.comment = comment; return this; } public MergeCommand setCommit(boolean commit) { this.commit = commit; return this; } public void execute() throws GitException, InterruptedException { ArgumentListBuilder args = new ArgumentListBuilder(); args.add("merge"); if(squash) { args.add("--squash"); } if(!commit){ args.add("--no-commit"); } if (comment != null && !comment.isEmpty()) { args.add("-m"); args.add(comment); } if (strategy != null && !strategy.isEmpty() && !strategy.equals(MergeCommand.Strategy.DEFAULT.toString())) { args.add("-s"); if(strategy.equals(MergeCommand.Strategy.RECURSIVE_THEIRS.toString())) { args.add("recursive"); args.add("--strategy-option"); args.add("theirs"); } else { args.add(strategy); } } args.add(fastForwardMode); args.add(rev.name()); <START> String repoUrl = getRemoteUrl(getDefaultRemote()); <END> StandardCredentials cred = credentials.get(repoUrl); if (cred == null) cred = defaultCredentials; launchCommandWithCredentials(args, workspace, cred, repoUrl); } }; }</code><technical_language>Merge is allowed if a remote URL is defined. If is remote URL, is need credentials in merge. I credentials in merge if is a remote URL, launch command credentials</technical_language>

Target:
public MergeCommand merge() { return new MergeCommand() { public ObjectId rev; public String comment; public String strategy; public String fastForwardMode; public boolean squash; public boolean commit = true; public MergeCommand setRevisionToMerge(ObjectId rev) { this.rev = rev; return this; } public MergeCommand setStrategy(MergeCommand.Strategy strategy) { this.strategy = strategy.toString(); return this; } public MergeCommand setGitPluginFastForwardMode(MergeCommand.GitPluginFastForwardMode fastForwardMode) { this.fastForwardMode = fastForwardMode.toString(); return this; } public MergeCommand setSquash(boolean squash) { this.squash = squash; return this; } public MergeCommand setMessage(String comment) { this.comment = comment; return this; } public MergeCommand setCommit(boolean commit) { this.commit = commit; return this; } public void execute() throws GitException, InterruptedException { ArgumentListBuilder args = new ArgumentListBuilder(); args.add("merge"); if(squash) { args.add("--squash"); } if(!commit){ args.add("--no-commit"); } if (comment != null && !comment.isEmpty()) { args.add("-m"); args.add(comment); } if (strategy != null && !strategy.isEmpty() && !strategy.equals(MergeCommand.Strategy.DEFAULT.toString())) { args.add("-s"); if(strategy.equals(MergeCommand.Strategy.RECURSIVE_THEIRS.toString())) { args.add("recursive"); args.add("--strategy-option"); args.add("theirs"); } else { args.add(strategy); } } args.add(fastForwardMode); args.add(rev.name()); String defaultRemote = null; try { defaultRemote = getDefaultRemote(); } catch (GitException e) { } if (defaultRemote != null && !defaultRemote.isEmpty()) { String repoUrl = getRemoteUrl(defaultRemote); StandardCredentials cred = credentials.get(repoUrl); if (cred == null) cred = defaultCredentials; launchCommandWithCredentials(args, workspace, cred, repoUrl); } else { launchCommand(args); } } }; }