Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diff:add option to ignore blank line changes #5853

Merged
merged 1 commit into from
May 19, 2021

Conversation

yuuri
Copy link
Contributor

@yuuri yuuri commented May 1, 2021

I found out that we have defined the parameter (XDF_IGNORE_BLANK_LINES) is in src/xdiff/xdiff.h.

I added support for this parameter(GIT_DIFF_IGNORE_BLANK_LINES) in include/git2/diff.h and src/diff_xdiff.c
This is my first PR, if there is anything wrong, please point it out and I will be happy to improve it.😊

@yuuri yuuri force-pushed the diff-ignore-blank-lines branch from 7d3114f to ed94f54 Compare May 1, 2021 12:27
@ethomson
Copy link
Member

ethomson commented May 6, 2021

Hi @yuuri! Looks good! One thing that would be really helpful would be a test that exercises the behavior. Would you be able to add one?

Our test framework is bespoke so I’m happy to help - but if you can provide the inputs and the “what would git do” output with this flag, that would be a great start!

@yuuri
Copy link
Contributor Author

yuuri commented May 7, 2021

Wow,@ethomson.Thanks for your comment! I am now reading the test code,so when understand it,I will add test function at once.
Now,please allow me to show you what I want to say.

As we known,when we want to show diff compare two commit,we can use git diff commit_sha1 commit_sha2,
it will show us two commit difference.And I notice git diff can add a parameter to ignore blank lines. Command look likes this
git diff --ignore-blank-lines

  1. origin diff show
$ git diff
diff --git a/main.py b/main.py
index b847ef7..42c5793 100644
--- a/main.py
+++ b/main.py
@@ -15,6 +15,10 @@ class Question:
         response = requests.get(api_url)
         return response.json()

+
+    def test_func(self):
+        pass
+
     def parser_json(self):
         info = self.request_url()
         question_info = info.get('stat_status_pairs', None)
@@ -25,6 +29,7 @@ class Question:
             info_list.append(info_dict)

         df = DataFrame(info_list)
+
         df.to_csv('question.csv')
         print(df)

2.when i add --ignore-blank-lines

$ git diff --ignore-blank-lines
diff --git a/main.py b/main.py
index b847ef7..42c5793 100644
--- a/main.py
+++ b/main.py
@@ -15,6 +15,10 @@ class Question:
         response = requests.get(api_url)
         return response.json()

+
+    def test_func(self):
+        pass
+
     def parser_json(self):
         info = self.request_url()
         question_info = info.get('stat_status_pairs', None)

I want make libgit2 to support feature like this.

@ethomson ethomson merged commit ed94f54 into libgit2:main May 19, 2021
@ethomson
Copy link
Member

Hi @yuuri - thanks again for the patch. I added 6b1f6e0 as a unit test on top!

@yuuri
Copy link
Contributor Author

yuuri commented May 19, 2021

@ethomson,Thank you very much! I will learn how to write test func by your code 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants