From 36fdb7fc8713f3d38ad5cc4cfa20f540aa22ed12 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 16 Feb 2012 16:23:33 +0400 Subject: [PATCH] git fetch --prune only since 1.7.0 Lazy to determine the concrete version, since it is a minor functionality. --- .../git4idea/src/git4idea/config/GitVersionSpecialty.java | 7 +++++++ plugins/git4idea/src/git4idea/update/GitFetcher.java | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/git4idea/src/git4idea/config/GitVersionSpecialty.java b/plugins/git4idea/src/git4idea/config/GitVersionSpecialty.java index c5104f9fb9ab..3c3f384249b2 100644 --- a/plugins/git4idea/src/git4idea/config/GitVersionSpecialty.java +++ b/plugins/git4idea/src/git4idea/config/GitVersionSpecialty.java @@ -73,6 +73,13 @@ public enum GitVersionSpecialty { } }, + SUPPORTS_FETCH_PRUNE { + @Override + public boolean existsIn(@NotNull GitVersion version) { + return version.isLaterOrEqual(new GitVersion(1, 7, 0, 0)); + } + }, + DOESNT_DEFINE_HOME_ENV_VAR { @Override public boolean existsIn(@NotNull GitVersion version) { diff --git a/plugins/git4idea/src/git4idea/update/GitFetcher.java b/plugins/git4idea/src/git4idea/update/GitFetcher.java index b3bcd4496e90..27f8c8c68b11 100644 --- a/plugins/git4idea/src/git4idea/update/GitFetcher.java +++ b/plugins/git4idea/src/git4idea/update/GitFetcher.java @@ -26,6 +26,7 @@ import com.intellij.openapi.vfs.VirtualFile; import git4idea.GitVcs; import git4idea.NotificationManager; import git4idea.commands.*; +import git4idea.config.GitVersionSpecialty; import git4idea.jgit.GitHttpAdapter; import git4idea.repo.GitRemote; import git4idea.repo.GitRepository; @@ -52,6 +53,7 @@ public class GitFetcher { private final Project myProject; private final GitRepositoryManager myRepositoryManager; private final ProgressIndicator myProgressIndicator; + private final GitVcs myVcs; private final Collection myErrors = new ArrayList(); @@ -59,6 +61,7 @@ public class GitFetcher { myProject = project; myProgressIndicator = progressIndicator; myRepositoryManager = GitRepositoryManager.getInstance(project); + myVcs = GitVcs.getInstance(project); } /** @@ -101,7 +104,9 @@ public class GitFetcher { private GitFetchResult fetchNatively(@NotNull VirtualFile root, @NotNull GitRemote remote) { final GitLineHandlerPasswordRequestAware h = new GitLineHandlerPasswordRequestAware(myProject, root, GitCommand.FETCH); - h.addParameters("--prune"); + if (GitVersionSpecialty.SUPPORTS_FETCH_PRUNE.existsIn(myVcs.getVersion())) { + h.addParameters("--prune"); + } h.addParameters(remote.getName()); final GitTask fetchTask = new GitTask(myProject, h, "Fetching..."); fetchTask.setProgressIndicator(myProgressIndicator);