nodegit / nodegit/nodegit

Merge.bases only returns one Oid

Open
#1,231 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
JavaScript
Stars
5.8k
Forks
704
PR merge metrics
No merged PRs in 30d

Description

How do you get multiple Oid out of an an Oid array? The Oids don't seems to be indexes, a call to oidarray.ids() returns one Oid, and multiple calls return the same Oid.

Setup:

git init
git commit --allow-empty --message foo1
git checkout -b dev
git commit --allow-empty --message foo2
git checkout master
git commit --allow-empty --message foo3
git merge -m "first merge base" dev
git checkout dev
git merge -m "second merge base" master~1
git merge-base --all master dev
# cac0d9e9c4d20fa2d09dcc9dfdbe44fcb5ad60d3
# 986123894e73887c35a1ee8294e9a17f1536144d

Script:

'use strict';

const git = require('nodegit');

function branchesOid(repo) {
  return Promise.all([
    repo.getReferenceCommit('master'),
    repo.getReferenceCommit('dev'),
  ]).then(commits => commits.map(c => c.id()));
}

git.Repository.open('.git').then(repo => {
  return branchesOid(repo).then(oid => git.Merge.bases(repo, ...oid))
}).then(oidarray => console.log(
  oidarray.count(),
  oidarray[0],
  oidarray[1],
  oidarray.ids(),
  oidarray.ids()
));

Result:

$ node merge-base.js
2 undefined undefined [Oid cac0d9e9c4d20fa2d09dcc9dfdbe44fcb5ad60d3] [Oid cac0d9e9c4d20fa2d09dcc9dfdbe44fcb5ad60d3]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the merge-base.js reproduction and tracing the git.Merge.bases entry point in the NodeGit bindings. Done means the returned collection exposes both merge-base Oids consistently, including through the access patterns shown in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, javascript, node.js
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.