Skip to content

Commit 9c3b665

Browse files
author
Gabriel Roldan
committed
Fix pull not doing anything when refs are already up-to-date
Signed-off-by: Gabriel Roldan <[email protected]>
1 parent 1988798 commit 9c3b665

File tree

2 files changed

+19
-11
lines changed
  • src/remoting/src

2 files changed

+19
-11
lines changed

src/remoting/src/main/java/org/locationtech/geogig/remotes/PullOp.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import static com.google.common.base.Preconditions.checkNotNull;
1414

1515
import java.util.ArrayList;
16-
import java.util.Collection;
1716
import java.util.List;
1817

1918
import org.eclipse.jdt.annotation.Nullable;
@@ -234,16 +233,6 @@ protected PullResult _call() {
234233
result.setOldRef(currentBranch);
235234
result.setRemote(suppliedRemote);
236235

237-
// did fetch need to update any contents?
238-
{
239-
final Collection<RefDiff> fetchedRefs = fetchResult.getRefDiffs()
240-
.get(remote.getFetchURL());
241-
if (fetchedRefs == null || fetchedRefs.isEmpty()) {
242-
result.setNewRef(currentBranch);
243-
return result;
244-
}
245-
}
246-
247236
for (LocalRemoteRefSpec fetchspec : remote.getFetchSpecs()) {
248237
final String localRemoteRefName = fetchspec.getLocal();
249238
final Optional<Ref> localRemoteRefOpt = command(RefParse.class)

src/remoting/src/test/java/org/locationtech/geogig/test/integration/remoting/PullOpTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,25 @@ public void testPullMerge() throws Exception {
166166
assertEquals(expectedMaster, logged);
167167
}
168168

169+
@Test
170+
public void testPullMergeNothingToFetch() throws Exception {
171+
// Add a commit to the remote
172+
insertAndAdd(remoteGeogig.geogig, lines3);
173+
RevCommit commit = commit(remoteGeogig.repo, "lines3");
174+
expectedMaster.addFirst(commit);
175+
176+
// call fetch first so the missing objects are already in the local repo
177+
fetchOp().call();
178+
179+
// Then Pull should update the target ref even if there's nothing to fetch
180+
PullOp pull = pullOp();
181+
pull.setRemote("origin").call();
182+
183+
List<RevCommit> logged = log(localGeogig.repo);
184+
185+
assertEquals(expectedMaster, logged);
186+
}
187+
169188
/**
170189
* Pull from a remote that's not being saved as named remote in the repository
171190
*/

0 commit comments

Comments
 (0)