libgit2 / libgit2/rugged

Walker returns incorrect results after upgrade from 0.25.0b9 to 0.25.0b10

Open
#673 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
2.3k
Forks
293
PR merge metrics
No merged PRs in 30d

Description

This is probably related to (https://github.com/libgit2/rugged/issues/663 /cc @cfillion).

Scenario:

Given a repository:

* commit C (HEAD)
|
* commit B
|
* commit A

When we do:

walker.push sha_of_a
walker.hide sha_of_c

Walker returns 1 commit (commit A) instead of 0 commits. This happens only when using Rugged::SORT_DATE.

Script to reproduce
gem 'rugged', "= #{ENV['RUGGED_VERSION']}"
require 'rugged'
require 'tmpdir'

Class.new do
  def initialize
    path = Dir.mktmpdir 'test-repository'
    @repo = Rugged::Repository.init_at path
    @repo.config['user.name'] = 'John Doe'
    @repo.config['user.email'] = 'john@doe.com'

    @hash_a = create_commit
    sleep 1
    @hash_b = create_commit
    sleep 1
    @hash_c = create_commit

    puts Rugged::VERSION
    compare
  end

  def create_commit
    Rugged::Commit.create @repo,
      message: 'Hello World',
      parents: @repo.empty? ? [] : [@repo.head.target].compact,
      tree: @repo.index.write_tree(@repo),
      update_ref: 'HEAD'
  end

  def compare
    walker = Rugged::Walker.new @repo
    walker.sorting(Rugged::SORT_DATE)

    walker.push @hash_a
    walker.hide @hash_c

    commits = walker.to_a
    walker.reset

    puts commits.size
  end
end.new
> RUGGED_VERSION=0.25.0b9 ruby rugged.rb
0.25.0b9
0
> RUGGED_VERSION=0.25.0b10 ruby rugged.rb
0.25.0b10
1

Contributor guide

No contributing guide indexed for this repository

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 with the reproduction script in the issue and run it against Rugged 0.25.0b9 and 0.25.0b10. Trace the Rugged::Walker path used by SORT_DATE, focusing on push and hide for the A-to-C history. Done means the scenario returns zero commits under 0.25.0b10 while preserving the expected behavior for the earlier version.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, ruby
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.