aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonrad Kügler2014-02-11 17:01:04 -0500
committerMatthias Sohn2014-02-12 18:16:33 -0500
commit420cb50cc2eeaaa85cc06f605c7a61fa4798a04e (patch)
treee1f5101af67e04c75b2e5f84aa835010ea87c8ed
parentd86c88308231b79a4b569032546c4043570c3921 (diff)
downloadjgit-420cb50cc2eeaaa85cc06f605c7a61fa4798a04e.zip
jgit-420cb50cc2eeaaa85cc06f605c7a61fa4798a04e.tar.gz
jgit-420cb50cc2eeaaa85cc06f605c7a61fa4798a04e.tar.xz
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: https://github.com/git/git/commit/737c5a9cde708d6995c765b7c2e95033edd0a896 Change-Id: Ida79d335218e1c9f5c6e2ce03386ac8a1c0b212e Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java20
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java14
2 files changed, 30 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
index 69c4923..29d475a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
@@ -54,10 +54,12 @@ import org.eclipse.jgit.errors.NoRemoteRepositoryException;
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;
@@ -81,7 +83,7 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
private boolean checkFetchedObjects;
- private boolean removeDeletedRefs;
+ private Boolean removeDeletedRefs;
private boolean dryRun;
@@ -118,7 +120,7 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
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);
@@ -199,7 +201,17 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
* @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;
+ }
}
/**
@@ -210,7 +222,7 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
*/
public FetchCommand setRemoveDeletedRefs(boolean removeDeletedRefs) {
checkCallable();
- this.removeDeletedRefs = removeDeletedRefs;
+ this.removeDeletedRefs = Boolean.valueOf(removeDeletedRefs);
return this;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
index bca79f2..1a09459 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
@@ -90,6 +90,13 @@ public class ConfigConstants {
/** The "pack" section */
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 */
public static final String CONFIG_KEY_ALGORITHM = "algorithm";
@@ -247,4 +254,11 @@ public class ConfigConstants {
* @since 3.0
*/
public static final String CONFIG_KEY_RENAMES = "renames";
+
+ /**
+ * The "prune" key
+ *
+ * @since 3.3
+ */
+ public static final String CONFIG_KEY_PRUNE = "prune";
}