Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SwapGIT_DIFF_LINE_(ADD|DEL)_EOFNL to match other Diffs#6240

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

xphoniex
Copy link
Contributor

Generating a diff usinggit_diff_tree_to_tree andgit_diff_from_buffer return different result for the same patch of:

$ git diff 17ec0f3 394a717diff --git a/.env b/.envindex f9fb22f..ed7b51e 100644--- a/.env+++ b/.env@@ -1 +1 @@-hello=12345+hello=123456\ No newline at end of file

Diff:

from repo:::- hello=12345+ hello=123456<                // Notice missing \n and `<` origin, meaning deletion\ No newline at end of file.from buff:::- hello=12345+ hello=123456> \ No newline at end of file

We didn't add the LF, we deleted it!

Signed-off-by: xphoniex <dj.2dixx@gmail.com>
@xphoniex
Copy link
ContributorAuthor

I'm looking at failed CIs and can't really tell if there's something wrong with the code when it showing leaked memory or something wrong with bitbucket that's causing this. Can you please take a look@ethomson ?

Test code is pretty straighforward, and the only thing I'm not freeing isgit_diff_line *line; which I couldn't find a_free function for e.g.git_diff_line_free.

@xphoniex
Copy link
ContributorAuthor

Polite reminder@ethomson .

@ethomson
Copy link
Member

Sorry for the long delay here — every time I came back to this PR, I was puzzled by the behavior. My misunderstanding was in the names of the constants — theline we're adding has a NL problem, this shouldn't that beGIT_DIFF_LINE_ADD_EOFNL?

In fact, no:

include/git2/diff.h:GIT_DIFF_LINE_ADD_EOFNL = '>',     /**< Old has no LF at end, new does */include/git2/diff.h:GIT_DIFF_LINE_DEL_EOFNL = '<',     /**< Old has LF at end, new does not */

SoGIT_DIFF_LINE_ADD_EOFNL means that the postimage (the delete) has the NL problem. 🥴

Thanks again for the fix.

cloudhead and FintanH reacted with laugh emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@xphoniex@ethomson

[8]ページ先頭

©2009-2025 Movatter.jp