Skip to content

Commit 4b5644a

Browse files
author
Michelle Tilley
authored
Merge pull request git-school#77 from git-school/mkt-fix-pull-merge
Fix pulling with merges
2 parents 1a44539 + bef7397 commit 4b5644a

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

js/controlbox.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -643,20 +643,22 @@ function(_yargs, d3, demos) {
643643
}
644644

645645
// determine which commits the local repo is missing from the origin
646+
function checkCommit (commit, branch) {
647+
var notInLocal = local.getCommit(commit.id) === null
648+
if (notInLocal && commit.id) {
649+
if (fetchIds.indexOf(commit.id) === -1) {
650+
fetchCommits.unshift(commit)
651+
fetchIds.unshift(commit.id)
652+
}
653+
fetchBranches[branch] += 1
654+
commit.parent && checkCommit(origin.getCommit(commit.parent), branch)
655+
commit.parent2 && checkCommit(origin.getCommit(commit.parent2), branch)
656+
}
657+
}
658+
646659
for (fb in fetchBranches) {
647660
if (origin.branches.indexOf(fb) > -1) {
648-
fetchCommit = origin.getCommit(fb);
649-
650-
var notInLocal = local.getCommit(fetchCommit.id) === null;
651-
while (notInLocal) {
652-
if (fetchIds.indexOf(fetchCommit.id) === -1) {
653-
fetchCommits.unshift(fetchCommit);
654-
fetchIds.unshift(fetchCommit.id);
655-
}
656-
fetchBranches[fb] += 1;
657-
fetchCommit = origin.getCommit(fetchCommit.parent);
658-
notInLocal = local.getCommit(fetchCommit.id) === null;
659-
}
661+
checkCommit(origin.getCommit(fb))
660662
}
661663
}
662664

@@ -666,6 +668,7 @@ function(_yargs, d3, demos) {
666668
local.commitData.push({
667669
id: fetchCommit.id,
668670
parent: fetchCommit.parent,
671+
parent2: fetchCommit.parent2,
669672
tags: []
670673
});
671674
}

0 commit comments

Comments
 (0)