libgit2 / libgit2/rugged

Rugged::Commit#diff doesn't seem to return the expected values

Open
#651 0 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

The following script walks over a local clone of https://github.com/ruby-gnome2/ruby-gnome2 and for the commits done at or after the day 2016-11-06, it displays the number of diff.

require "rugged"
require "date"

git_dir = "./ruby-gnome2/"

repo = Rugged::Repository.new(git_dir)
walker = Rugged::Walker.new(repo)
walker.sorting(Rugged::SORT_DATE| Rugged::SORT_REVERSE)
walker.push(repo.head.target)

walker.each do |commit|
  c_time = Time.at(commit.time)
  next unless c_time >= Date.new(2016,11,6).to_time

    puts c_time
    puts commit.diff.size
    puts commit.diff.stat.inspect
end

Here is the output:

ruby rugged_log.rb 
2016-11-06 06:25:04 +0100
2463
[2463, 0, 271333]
2016-11-06 06:26:42 +0100
2463
[2463, 0, 271338]
2016-11-06 09:43:32 +0100
2463
[2463, 0, 271338]
2016-11-06 09:43:59 +0100
2463
[2463, 0, 271338]
2016-11-06 13:30:14 +0100
2463
[2463, 0, 271338]
2016-11-06 14:08:08 +0100
2463
[2463, 0, 271340]

This means that for each commit there are 2463 files modified/deleted. The git command git log --name-status --oneline --after="2016-11-05" shows that it is not true:


965f344 Merge pull request #947 from cedlemo/gtk3_setlocale_C
fa07714 Merge pull request #953 from cedlemo/gstreamer_sample_text_color_example_rb
108bee8 Update copyright date
M       gstreamer/sample/text-color-example.rb
8b5b194 Use the method that returns a clock even if the pipeline is not playing
M       gstreamer/sample/text-color-example.rb
a1f5ee5 gi: return value is return type is void but pointer
M       gobject-introspection/lib/gobject-introspection/callable-info.rb
M       gobject-introspection/lib/gobject-introspection/loader.rb
204c40f gi: do nothing for void type return type
M       gobject-introspection/ext/gobject-introspection/rb-gi-argument.c

What am I doing wrong?

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

Run the supplied Ruby reproduction against the referenced ruby-gnome2 clone, then compare Rugged::Commit#diff and diff.stat with the shown git log output. Trace the Rugged::Commit#diff entry point; no source file or test is named in the issue. Done means explaining the discrepancy or providing behavior and regression coverage that match the intended per-commit diff results.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.