Skip to content

Diff.merge: inconsistent behavior #1002

Description

@smith-kyle

I have two diffs, one from commit.getDiffWithOptions and one from NodeGit.Diff.treeToWorkdirWithIndex where the tree is from the head commit. They were made with the same options. When merging the two diffs, depending on which diff is merged into which, either the diffs will merge or this error will be thrown:

Error: Attempt to merge diffs created with conflicting options

Here's some kind of pseudo code

let workDirWithIndexDiff;
repo.getHeadCommit()
  .then(headCommit => headCommit.getTree())
  .then(headTree => NodeGit.Diff.treeToWorkdirWithIndex(repo, headTree, {}))
  .then(_workDirWithIndexDiff => {
    workDirWithIndexDiff = _workDirWithIndexDiff;
    return someCommit.getDiffWithOptions({});
  })
  .then(someDiff => {
    // This would reject with Error: Attempt to merge diffs created with conflicting options
    someDiff.merge(workDirWithIndexDiff);

    // This would resolve
    workDirWithIndexDiff.merge(someDiff);
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions