| 238 | } |
| 239 | |
| 240 | inline void syncWithRemote(const std::shared_ptr<Repository>& repository) |
| 241 | { |
| 242 | if (repository->mergeIsInProgress()) |
| 243 | { |
| 244 | throw GitException(_("Merge in progress")); |
| 245 | } |
| 246 | |
| 247 | if (GlobalMapModule().isModified()) |
| 248 | { |
| 249 | throw GitException(_("The map file has unsaved changes, please save before merging.")); |
| 250 | } |
| 251 | |
| 252 | auto mapPath = repository->getRepositoryRelativePath(GlobalMapModule().getMapName()); |
| 253 | |
| 254 | RemoteStatus status = analyseRemoteStatus(repository); |
| 255 | |
| 256 | switch (status.strategy) |
| 257 | { |
| 258 | case RequiredMergeStrategy::NoMergeRequired: |
| 259 | rMessage() << "No merge required." << std::endl; |
| 260 | return; |
| 261 | |
| 262 | case RequiredMergeStrategy::JustPush: |
| 263 | repository->pushToTrackedRemote(); |
| 264 | return; |
| 265 | |
| 266 | case RequiredMergeStrategy::FastForward: |
| 267 | performFastForward(repository); |
| 268 | return; |
| 269 | } |
| 270 | |
| 271 | // All the other merge strategies include a recursive merge, prepare it |
| 272 | if (status.strategy == RequiredMergeStrategy::MergeMapWithUncommittedChanges) |
| 273 | { |
| 274 | // Commit the current map changes |
| 275 | wxutil::Messagebox::Show(_("Pending Commit"), |
| 276 | _("The map file has uncommitted changes, please commit first before integrating."), |
| 277 | ::ui::IDialog::MessageType::MESSAGE_CONFIRM); |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | if (!repository->isReadyForMerge()) |
| 282 | { |
| 283 | throw git::GitException(_("Repository is not ready for a merge at this point")); |
| 284 | } |
| 285 | |
| 286 | if (!repository->getHead() || !repository->getHead()->getUpstream()) |
| 287 | { |
| 288 | throw git::GitException(_("Cannot resolve HEAD and the corresponding upstream branch")); |
| 289 | } |
| 290 | |
| 291 | git_merge_analysis_t analysis; |
| 292 | git_merge_preference_t preference = GIT_MERGE_PREFERENCE_NONE; |
| 293 | |
| 294 | auto upstream = repository->getHead()->getUpstream(); |
| 295 | git_oid upstreamOid; |
| 296 | auto error = git_reference_name_to_id(&upstreamOid, repository->_get(), upstream->getName().c_str()); |
| 297 |
no test coverage detected