Skip to content

Cannot parse diffstat generated by git format-patch #27

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

Open
gagath opened this issue Sep 22, 2024 · 0 comments · May be fixed by #28
Open

Cannot parse diffstat generated by git format-patch #27

gagath opened this issue Sep 22, 2024 · 0 comments · May be fixed by #28

Comments

@gagath
Copy link

gagath commented Sep 22, 2024

The parser interprets the --- at the beginning of a diffstat as a file modified in a patch instead of ignoring at as part of the patch message. Below is an example patch generated by git format-patch that will fail to be parsed because of the diffstat:

From c285d896b6ef509291860351d246e82a83e9d96a Mon Sep 17 00:00:00 2001
From: Foo Bar <[email protected]>
Date: Mon, 9 Sep 2024 21:14:30 +0200
Subject: [PATCH] Test commit

---
 modified_file | 4 +++-
 new_file      | 4 ++++
 removed_file  | 3 ---
 3 files changed, 7 insertions(+), 4 deletions(-)
 create mode 100644 new_file
 delete mode 100644 removed_file

diff --git a/modified_file b/modified_file
index c368d8f..922fd19 100644
--- a/modified_file
+++ b/modified_file
@@ -1,5 +1,7 @@
 This is the original content.
 
-This should be updated.
+This is now updated.
+
+This is a new line.
 
 This will stay.
diff --git a/new_file b/new_file
new file mode 100644
index 0000000..7056bca
--- /dev/null
+++ b/new_file
@@ -0,0 +1,4 @@
+This was missing!
+Adding it now.
+
+Only for testing purposes.
diff --git a/removed_file b/removed_file
deleted file mode 100644
index 9b89750..0000000
--- a/removed_file
+++ /dev/null
@@ -1,3 +0,0 @@
-This content shouldn't be here.
-
-This file will be removed.
gagath added a commit to gagath/patch-rs that referenced this issue Sep 22, 2024
The parser was not accepting diffstat from git format-patch files.
This patch fixes this issue and rewrites the git.diff file to contain
the full output of a git format-patch command to exercise the parser
(minus the git version, as this would trigger an assert error because of
remaining content).

Fixes uniphil#27
gagath added a commit to gagath/patch-rs that referenced this issue Sep 22, 2024
The parser was not accepting diffstat from git format-patch files.
This patch fixes this issue and rewrites the git.diff file to contain
the full output of a git format-patch command to exercise the parser
(minus the git version, as this would trigger an assert error because of
remaining content).

Fixes uniphil#27
@gagath gagath linked a pull request Sep 22, 2024 that will close this issue
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 a pull request may close this issue.

1 participant