import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.errors.TransportException;
import org.eclipse.jgit.internal.JGitText;
+import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.TagOpt;
private boolean checkFetchedObjects;
- private boolean removeDeletedRefs;
+ private Boolean removeDeletedRefs;
private boolean dryRun;
Transport transport = Transport.open(repo, remote);
try {
transport.setCheckFetchedObjects(checkFetchedObjects);
- transport.setRemoveDeletedRefs(removeDeletedRefs);
+ transport.setRemoveDeletedRefs(isRemoveDeletedRefs());
transport.setDryRun(dryRun);
if (tagOption != null)
transport.setTagOpt(tagOption);
* @return whether or not to remove refs which no longer exist in the source
*/
public boolean isRemoveDeletedRefs() {
- return removeDeletedRefs;
+ if (removeDeletedRefs != null)
+ return removeDeletedRefs.booleanValue();
+ else { // fall back to configuration
+ boolean result = false;
+ StoredConfig config = repo.getConfig();
+ result = config.getBoolean(ConfigConstants.CONFIG_FETCH_SECTION,
+ null, ConfigConstants.CONFIG_KEY_PRUNE, result);
+ result = config.getBoolean(ConfigConstants.CONFIG_REMOTE_SECTION,
+ remote, ConfigConstants.CONFIG_KEY_PRUNE, result);
+ return result;
+ }
}
/**
*/
public FetchCommand setRemoveDeletedRefs(boolean removeDeletedRefs) {
checkCallable();
- this.removeDeletedRefs = removeDeletedRefs;
+ this.removeDeletedRefs = Boolean.valueOf(removeDeletedRefs);
return this;
}