mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Git fetch: update remote branch ref
'git fetch origin master' only updates the FETCH_HEAD without updating refs/remotes/origin/master. We don't read FETCH_HEAD for merging, preferring to call 'git log master..origin/master' to decide if we need to merge => updating the remote ref is necessary. Supply the full refspec to 'git fetch' to update the remote ref.
This commit is contained in:
@@ -46,6 +46,9 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static git4idea.GitBranch.REFS_HEADS_PREFIX;
|
||||
import static git4idea.GitBranch.REFS_REMOTES_PREFIX;
|
||||
|
||||
/**
|
||||
* @author Kirill Likhodedov
|
||||
*/
|
||||
@@ -158,10 +161,14 @@ public class GitFetcher {
|
||||
if (GitVersionSpecialty.SUPPORTS_FETCH_PRUNE.existsIn(myVcs.getVersion())) {
|
||||
h.addParameters("--prune");
|
||||
}
|
||||
h.addParameters(remote.getName());
|
||||
|
||||
String remoteName = remote.getName();
|
||||
h.addParameters(remoteName);
|
||||
if (branch != null) {
|
||||
h.addParameters(branch);
|
||||
branch = getRidOfPrefixIfExists(branch);
|
||||
h.addParameters(REFS_HEADS_PREFIX + branch + ":" + REFS_REMOTES_PREFIX + remoteName + "/" + branch);
|
||||
}
|
||||
|
||||
final GitTask fetchTask = new GitTask(myProject, h, "Fetching...");
|
||||
fetchTask.setProgressIndicator(myProgressIndicator);
|
||||
fetchTask.setProgressAnalyzer(new GitStandardProgressAnalyzer());
|
||||
@@ -198,6 +205,13 @@ public class GitFetcher {
|
||||
return result.get();
|
||||
}
|
||||
|
||||
private static String getRidOfPrefixIfExists(String branch) {
|
||||
if (branch.startsWith(REFS_HEADS_PREFIX)) {
|
||||
return branch.substring(REFS_HEADS_PREFIX.length());
|
||||
}
|
||||
return branch;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<Exception> getErrors() {
|
||||
return myErrors;
|
||||
|
||||
Reference in New Issue
Block a user