-
Notifications
You must be signed in to change notification settings - Fork 27
Comparing changes
Open a pull request
base repository: bluekeyes/go-gitdiff
base: v0.7.0
head repository: bluekeyes/go-gitdiff
compare: master
- 13 commits
- 40 files changed
- 2 contributors
Commits on Dec 26, 2022
-
Fix parsing of mode lines with trailing space (#38)
If a patch is passed through a system that converts line endings to '\r\n', mode lines end up with trailing whitespace that confuses strconv.ParseInt. In Git, this is avoided by using strtoul() for parsing, which stops at the first non-digit character. Changing line endings in patch content itself will cause other problems so it is best to avoid this transform, but if it does happen, it shouldn't cause a parse error.
Configuration menu - View commit details
-
Copy full SHA for 981bc4b - Browse repository at this point
Copy the full SHA 981bc4bView commit details
Commits on Feb 25, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 13e8639 - Browse repository at this point
Copy the full SHA 13e8639View commit details
Commits on Mar 7, 2024
-
Accept empty emails in ParsePatchIdentity (#42)
Git is actually more lenient here than I thought. As long as the identity contains the "<>" delimiters, Git will allow an empty email, so we should accept the same thing. I also discovered that an identity with only an email set will use the email as the name, so I've implemented that behavior as well.
Configuration menu - View commit details
-
Copy full SHA for 3f2ea5c - Browse repository at this point
Copy the full SHA 3f2ea5cView commit details
Commits on May 6, 2024
-
Follow git logic when parsing patch identities (#44)
When GitHub creates patches for Dependabot PRs, it generates a "From:" line that is not valid according to RFC 5322: the address spec contains unquoted special characters (the "[bot]" in "dependabot[bot]"). While the 'net/mail' parser makes some exceptions to the spec, this is not one of them, so parsing these patch headers fails. Git's 'mailinfo' command avoids this by only implementing the unquoting part of RFC 5322 and then applying a heuristic to separate the string in to name and email values that seem reasonable. This commit does two things: 1. Reimplements ParsePatchIdentity to follow Git's logic, so that it can accept a wider range of inputs, including quoted strings. Strings accepted by the previous implementation parse in the same way with one exception: inputs that contain whitespace inside the angle brackets for an email address now use the email address as the name and drop any separate name component. 2. When parsing mail-formatted patches, use ParsePatchIdentity to parse the "From:" line instead of the 'net/mail' function.
Configuration menu - View commit details
-
Copy full SHA for a00d2cc - Browse repository at this point
Copy the full SHA a00d2ccView commit details
Commits on Jul 15, 2024
-
Return preamble when a patch has no files (#46)
While empty patches with only a header were parsable, the parser discarded the preamble content. This meant callers had to handle this case specially. Now, if we reach the end of the input without finding a file, Parse() returns the full content of the patch as the preamble.
Configuration menu - View commit details
-
Copy full SHA for 0a4e55f - Browse repository at this point
Copy the full SHA 0a4e55fView commit details
Commits on Aug 11, 2024
-
Update Go and golangci-lint versions (#49)
The minimum Go version for the package is now Go 1.21. This is because a future change will use the 'slices' package in test code. Note that non-test code in the package should still be compatible with older versions of Go. As part of this, also update the golangci-lint version to one that works with Go 1.21, which required replacing some deprecated linters.
Configuration menu - View commit details
-
Copy full SHA for 9e0997e - Browse repository at this point
Copy the full SHA 9e0997eView commit details -
Add String() methods to parsed types (#48)
This enables clients to move back and forth between parsed objects and text patches. The generated patches are semantically equal to the parsed object and should re-parse to the same object, but may not be byte-for-byte identical to the original input. In my testing, formatted text patches are usually identical to the input, but there may be cases where this is not true. Binary patches always differ. This is because Go's 'compress/flate' package ends streams with an empty block instead of adding the end-of-stream flag to the last non-empty block, like Git's C implementation. Since the streams will always be different for this reason, I chose to also enable default compression (the test patches I generated with Git used no compression.) The main tests for this feature involve parsing, formatting, and then re-parsing a patch to make sure we get equal objects. Formatting is handled by a new internal formatter type, which allows writing all data to the same stream. This isn't exposed publicly right now, but will be useful if there's a need for more flexible formatting functions in the future, like formatting to a user-provided io.Writer.
Configuration menu - View commit details
-
Copy full SHA for 8584cd5 - Browse repository at this point
Copy the full SHA 8584cd5View commit details
Commits on Jan 8, 2025
-
Parse binary headers with file paths (#55)
Some patches may include one or more file paths as part of the binary header when there is no binary data. Git accounts for this by only checking the prefix and suffix of the line, but I missed that logic when implementing this originally.
Configuration menu - View commit details
-
Copy full SHA for 14da3d3 - Browse repository at this point
Copy the full SHA 14da3d3View commit details -
Fix binary headers in formatted patches (#56)
Include file names in the header (now that we can actually parse them) and fix a bad find-and-replace that changed "differ" to "fmer". Add a new test to verify that binary files without data format correctly.
Configuration menu - View commit details
-
Copy full SHA for fffa3cc - Browse repository at this point
Copy the full SHA fffa3ccView commit details
Commits on Mar 5, 2025
-
Add a test for removing the last newline in a file (#59)
This worked, but completes the test coverage in combination with the test that adds a final newline and one that leaves the missing newline in place.
Configuration menu - View commit details
-
Copy full SHA for 823d31d - Browse repository at this point
Copy the full SHA 823d31dView commit details
Commits on Mar 29, 2025
-
Clarify that we only support GNU diff
In issue #57, it was reported that the library could not apply some patches generated by BSD `diff` because of the way that variant reports changes in files without trailing newlines. Since the library behavior matches Git, I don't consider this a bug, but update the README to mention that the support for standard unified diffs is only for the GNU variant of the `diff` tool.
Configuration menu - View commit details
-
Copy full SHA for 0896f01 - Browse repository at this point
Copy the full SHA 0896f01View commit details
Commits on Apr 1, 2025
-
Configuration menu - View commit details
-
Copy full SHA for 7413262 - Browse repository at this point
Copy the full SHA 7413262View commit details
Commits on Sep 4, 2025
-
Report short sources as conflicts during apply (#63)
Previously, this returned an io.ErrUnexpectedEOF. This is not wrong, in that we did unexpectedly hit the end of the input file, but it is vague and implies a possible library bug rather than a problem with the patch or the input. This condition is really a conflict, as the changes described by the patch are not compatible with the state of the input.
Configuration menu - View commit details
-
Copy full SHA for 17bd72f - Browse repository at this point
Copy the full SHA 17bd72fView commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff v0.7.0...master