Skip to content
This repository was archived by the owner on Dec 2, 2026. It is now read-only.
This repository was archived by the owner on Dec 2, 2026. It is now read-only.

Index randomly has conflict #816

Open

Description

@petemill

The following code simply creates a blank index, adds 1 file to it, and checks the index for conflict. When running multiple times, once after another, the index will randomly have a conflict, and the conflicted entry will be the only entry, with a stage value of 3.

I would expect there never to be a conflict. Is this a bug or have I misunderstood a concept?

return Git.Repository.init(this.repoPath, 0)
.then(repo => {

  return Git.Index.open('randomindexpath')
  .then(index => {

    //create file entry
    var fileContent = new Buffer("first file content");
    var newFileOid = Git.Blob.createFromBuffer(repo, fileContent, fileContent.length);
    var fileEntry = new Git.IndexEntry();
    fileEntry.path = 'firstfile.txt';
    fileEntry.id = newFileOid;
    fileEntry.mode = Git.TreeEntry.FILEMODE.BLOB;
    //add entry to index
    index.add(fileEntry);
    if (index.hasConflicts()) {
      throw new Error('Index is conflicted');
    }
  });
});

Activity

  1. petemill commented on Dec 9, 2015

    @petemill
    ContributorAuthor

    Added #820 which adds a test case, and enables Git.Index.create()

  2. johnhaley81 commented on Jan 21, 2016

    @johnhaley81
    Collaborator

    This might be related to #827.

  3. unframework commented on Feb 28, 2016

    @unframework

    I found that setting the index entry flags to 0 before adding to index seems to avoid the unexpected conflict state. Doing a dump showed that it might be left uninitialized otherwise, which probably confuses the add code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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