Skip to content

Commit

Permalink
Fix pull not doing anything when refs are already up-to-date
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Roldan <groldan@boundlessgeo.com>
  • Loading branch information
Gabriel Roldan committed Sep 11, 2018
1 parent 1988798 commit 9c3b665
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import static com.google.common.base.Preconditions.checkNotNull;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.eclipse.jdt.annotation.Nullable;
Expand Down Expand Up @@ -234,16 +233,6 @@ protected PullResult _call() {
result.setOldRef(currentBranch);
result.setRemote(suppliedRemote);

// did fetch need to update any contents?
{
final Collection<RefDiff> fetchedRefs = fetchResult.getRefDiffs()
.get(remote.getFetchURL());
if (fetchedRefs == null || fetchedRefs.isEmpty()) {
result.setNewRef(currentBranch);
return result;
}
}

for (LocalRemoteRefSpec fetchspec : remote.getFetchSpecs()) {
final String localRemoteRefName = fetchspec.getLocal();
final Optional<Ref> localRemoteRefOpt = command(RefParse.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,25 @@ public void testPullMerge() throws Exception {
assertEquals(expectedMaster, logged);
}

@Test
public void testPullMergeNothingToFetch() throws Exception {
// Add a commit to the remote
insertAndAdd(remoteGeogig.geogig, lines3);
RevCommit commit = commit(remoteGeogig.repo, "lines3");
expectedMaster.addFirst(commit);

// call fetch first so the missing objects are already in the local repo
fetchOp().call();

// Then Pull should update the target ref even if there's nothing to fetch
PullOp pull = pullOp();
pull.setRemote("origin").call();

List<RevCommit> logged = log(localGeogig.repo);

assertEquals(expectedMaster, logged);
}

/**
* Pull from a remote that's not being saved as named remote in the repository
*/
Expand Down

0 comments on commit 9c3b665

Please sign in to comment.