libgit2 / libgit2/libgit2sharp

Ignoring whitespaces on diff does not work

Đang mở
#1,858 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
C#
Star
3.5k
Fork
925
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Expected behavior

When I call:

  var options =
                new CompareOptions()
                {
                    ContextLines = Int32.MaxValue,
                    IncludeUnmodified = true,
                    Similarity =
                        new SimilarityOptions()
                        {
                            WhitespaceMode = WhitespaceMode.IgnoreAllWhitespace
                        }
                };

Console.Write(
   repo.Diff.Compare<Patch>(
      branch.Tip.Tree, 
      DiffTargets.Index | DiffTargets.WorkingDirectory, 
      files,
      null,
      options
   ).First().Patch
)

the output is the same as using the git command git diff --ignore-all-space:

diff --git a/test.txt b/test.txt
index d209983..b2c9980 100644
--- a/test.txt
+++ b/test.txt
@@ -1,2 +1,2 @@
 I am an  initial  content
-I am a changeable content
\ No newline at end of file
+I am a different content
\ No newline at end of file
Actual behavior

If have a file "test.txt" with committed content:

I am an inital content
I am a changeable content

and uncommitted content:

I am an  inital  content
I am a different content

(The first line has some additional whitespaces)

When I call:

  var options =
                new CompareOptions()
                {
                    ContextLines = Int32.MaxValue,
                    IncludeUnmodified = true,
                    Similarity =
                        new SimilarityOptions()
                        {
                            WhitespaceMode = WhitespaceMode.IgnoreAllWhitespace
                        }
                };

Console.Write(
   repo.Diff.Compare<Patch>(
      branch.Tip.Tree, 
      DiffTargets.Index | DiffTargets.WorkingDirectory, 
      files,
      null,
      options
   ).First().Patch
)

the output is

diff --git a/test.txt b/test.txt
index d209983..b2c9980 100644
--- a/test.txt
+++ b/test.txt
@@ -1,2 +1,2 @@
-I am an initial content
-I am a changeable content
\ No newline at end of file
+I am an  initial  content
+I am a different content
\ No newline at end of file
Version of LibGit2Sharp (release number or SHA1)

v0.26.2

Operating system(s) tested; .NET runtime tested

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện ví dụ Compare với CompareOptions, SimilarityOptions và WhitespaceMode.IgnoreAllWhitespace, sau đó so sánh đầu ra của nó với git diff --ignore-all-space. Theo dõi đường dẫn so sánh diff xử lý các chế độ Whitespace. Công việc được xem là hoàn tất khi các thay đổi chỉ bao gồm Whitespace bị bỏ qua, trong khi các thay đổi thực chất vẫn xuất hiện trong patch.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, git
Lĩnh vực
devtools
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.