Sfoglia il codice sorgente

Use fetch.prune and remote.<name>.prune to set prune mode when fetching

When no explicit value is set via FetchCommand.setRemoveDeletedRefs()
checks if pruning is enabled in the configuration.

The following commit introduced the prune config to C Git:
737c5a9cde

Change-Id: Ida79d335218e1c9f5c6e2ce03386ac8a1c0b212e
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v3.3.0.201402191814-rc1
Konrad Kügler 10 anni fa
parent
commit
420cb50cc2

+ 16
- 4
org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java Vedi File

import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.errors.TransportException;
import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ProgressMonitor; import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.transport.FetchResult; import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec; import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.TagOpt; import org.eclipse.jgit.transport.TagOpt;


private boolean checkFetchedObjects; private boolean checkFetchedObjects;


private boolean removeDeletedRefs;
private Boolean removeDeletedRefs;


private boolean dryRun; private boolean dryRun;


Transport transport = Transport.open(repo, remote); Transport transport = Transport.open(repo, remote);
try { try {
transport.setCheckFetchedObjects(checkFetchedObjects); transport.setCheckFetchedObjects(checkFetchedObjects);
transport.setRemoveDeletedRefs(removeDeletedRefs);
transport.setRemoveDeletedRefs(isRemoveDeletedRefs());
transport.setDryRun(dryRun); transport.setDryRun(dryRun);
if (tagOption != null) if (tagOption != null)
transport.setTagOpt(tagOption); transport.setTagOpt(tagOption);
* @return whether or not to remove refs which no longer exist in the source * @return whether or not to remove refs which no longer exist in the source
*/ */
public boolean isRemoveDeletedRefs() { 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) { public FetchCommand setRemoveDeletedRefs(boolean removeDeletedRefs) {
checkCallable(); checkCallable();
this.removeDeletedRefs = removeDeletedRefs;
this.removeDeletedRefs = Boolean.valueOf(removeDeletedRefs);
return this; return this;
} }



+ 14
- 0
org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java Vedi File

/** The "pack" section */ /** The "pack" section */
public static final String CONFIG_PACK_SECTION = "pack"; public static final String CONFIG_PACK_SECTION = "pack";


/**
* The "fetch" section
*
* @since 3.3
*/
public static final String CONFIG_FETCH_SECTION = "fetch";

/** The "algorithm" key */ /** The "algorithm" key */
public static final String CONFIG_KEY_ALGORITHM = "algorithm"; public static final String CONFIG_KEY_ALGORITHM = "algorithm";


* @since 3.0 * @since 3.0
*/ */
public static final String CONFIG_KEY_RENAMES = "renames"; public static final String CONFIG_KEY_RENAMES = "renames";

/**
* The "prune" key
*
* @since 3.3
*/
public static final String CONFIG_KEY_PRUNE = "prune";
} }

Loading…
Annulla
Salva