Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

fnmatch patterns has preblem in diff

オープン
#882 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
c, ruby
領域
tooling

調査の方向性

まずインラインの Minitest 再現コードを実行し、末尾に空白があるパスで失敗することを確認します。次に、既存の diff 呼び出しを入口として、Rugged の拡張機能から libgit2 との境界にまたがるパスフィルタリングを追跡します。テストに B パッチが含まれ、フィルタリングなしの場合と match を無効にした場合が引き続きパスすれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Summary

When target file path has a space(eg: 'README.md '), Rugged::Tree.diff(..., paths: ['README.md ']).patches return empty array.
This should be a problem caused by the ext or libgit2, but I have not learn C language and I can't fix it.
Can you help me deal with it? Thanks.

Steps to reproduce

# frozen_string_literal: true

require 'bundler/inline'

gemfile(true) do
  source 'https://gems.ruby-china.com'

  gem 'minitest'
  gem 'rugged'
end

require 'minitest/autorun'
require 'rugged'

class DiffBugTest < Minitest::Test
  def setup
    author = committer = { name: 'foobar', email: '[email protected]', time: Time.now }
    @repository = Rugged::Repository.init_at('/tmp/rugged_test_repository.git', true)

    @repository.index << { path: 'A', mode: 0o100644, oid: @repository.write('A file', :blob)}
    @repository.index << { path: 'B ', mode: 0o100644, oid: @repository.write('B file', :blob)} # NOTE: 'B ' path has a space
    @first_oid = Rugged::Commit.create(
      @repository,
      author: author,
      committer: committer,
      message: 'First commit',
      parents: [],
      tree: @repository.index.write_tree,
    )

    @repository.index << { path: 'A', mode: 0o100644, oid: @repository.write('Modified A file', :blob)}
    @repository.index << { path: 'B ', mode: 0o100644, oid: @repository.write('Modified B file', :blob)} # NOTE: 'B ' path has a space
    @second_oid = Rugged::Commit.create(
      @repository,
      author: author,
      committer: committer,
      message: 'Second commit',
      parents: [@first_oid],
      tree: @repository.index.write_tree,
    )
  end

  # NOTE: 'B ' path has a space
  def test_path_end_with_space
    # Success
    assert_equal 2, @repository.diff(@first_oid, @second_oid).patches.size
    assert_equal 2, @repository.diff(@first_oid, @second_oid, paths: ['A', 'B '], disable_pathspec_match: true).patches.size

    # Failure
    assert_equal 2, @repository.diff(@first_oid, @second_oid, paths: ['A', 'B ']).patches.size # => Missing 'B ' patch
  end
end

PS: English is not my native language; please excuse typing errors.

主要言語
C
スター
2.3k
フォーク
293
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

libgit2/rugged のほかの issue

libgit2/rugged の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。