首页 > 解决方案 > 用于解决并行加法的 Diff/merge 算法

问题描述

我们正在创建一种新的方法。它的一部分是一种实现模式,旨在使并行化编码成为可能。

只有少数几个领域存在冲突,它们应该很容易解决。编码人员只需添加代码块(常量和方法,在一种情况下,在方法中添加外观一致的表达式)。

然而,我们看到我们认为可以自动解决的冲突,但 git 不知何故无法解决它们。是否有选项或工具可以做到这一点?如果没有,可以使用什么算法以及如何将其集成到 git 中?

我尝试了以下方法:

git merge -X patience otherbranch
git merge -X patience -X diff-algorithm=patience otherbranch
git merge -X patience -X diff-algorithm=histogram otherbranch
git merge -s resolve  otherbranch
git merge -s renormalize  otherbranch
git merge -X patience -X diff-algorithm=histogram -X renormalize otherbranch
git merge -s subtree  otherbranch

以下是此类冲突的一些示例:

  1. 添加的字段

<<<<<<< feature/issue_105
  public static final String TASK_DESCRIPTION_START = "Task Description: \n";
  public static final String TASK_DESCRIPTION_END =
      "\n End of Task Description \n";
  public static final String DIFF = "Diff: \n";
=======

  public static final String BALANCE_LESS_THAN_USER_BUDGET =
      "The user balance is less than project budget";
>>>>>>> develop

  1. 添加了方法,差异对边界感到困惑

<<<<<<< feature/issue_151
  public static TaskEntity getTaskOne() {
    final TaskEntity taskEntity = get();
    taskEntity.setId(TaskTestData.ID_ONE);
    return taskEntity;
=======
  public static TaskEntity getGrabbedOverThreeDays() {
    final TaskEntity taskEntity = get();
    taskEntity.setStatus(TaskStatusEnum.IN_PROGRESS);
    taskEntity.setGrabDate(TaskTestData.DATE_OLDER_THAN_THREE_DAYS);
    return taskEntity;

>>>>>>> develop
  }

  1. 只添加了一侧

<<<<<<< feature/issue_135
=======
  public static MarketUserEntity getRoleProjectManager() {
    final MarketUserEntity marketUserEntity = get();
    marketUserEntity.setUser(UserEntityTestData.getRoleProjectManager());
    return marketUserEntity;
  }


>>>>>>> develop

标签: gitmergediff

解决方案


推荐阅读