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

Feature request: File creation from diff -ruN #8

Open
kit-ty-kate opened this issue Mar 20, 2024 · 2 comments
Open

Feature request: File creation from diff -ruN #8

kit-ty-kate opened this issue Mar 20, 2024 · 2 comments

Comments

@kit-ty-kate
Copy link
Collaborator

The documentation of GNU patch states:

You can create a file by sending out a diff that compares /dev/null or an empty file dated the
Epoch (1970-01-01 00:00:00 UTC) to the file you want to create.

This is used, for example by (GNU) diff -ruN, where the -N option reads:

-N, --new-file
treat absent files as empty

Currently, this implementation of patch would return Edit on such an input instead of the expected Create

kit-ty-kate added a commit to kit-ty-kate/opam that referenced this issue Mar 20, 2024
kit-ty-kate added a commit to kit-ty-kate/opam that referenced this issue Mar 20, 2024
kit-ty-kate added a commit to kit-ty-kate/opam that referenced this issue Mar 20, 2024
kit-ty-kate added a commit to kit-ty-kate/opam that referenced this issue Mar 20, 2024
kit-ty-kate added a commit to kit-ty-kate/opam that referenced this issue Mar 20, 2024
@hannesm
Copy link
Owner

hannesm commented Mar 21, 2024

a question I have: is this addressed in #9? If not, would you mind to post a small example?

@kit-ty-kate
Copy link
Collaborator Author

is this addressed in #9?

it is not.

If not, would you mind to post a small example?

With the following setup:

mkdir a b
echo aaa > a/test
diff -ruaN a b > patch

the outputted patch file looks like:

diff -ruaN a/test b/test
--- a/test	2024-03-21 11:29:11
+++ b/test	1970-01-01 01:00:00
@@ -1 +0,0 @@
-aaa

on macOS

diff -ruaN a/test b/test
--- a/test	Thu Mar 21 12:34:45 2024
+++ b/test	Thu Jan  1 01:00:00 1970
@@ -1 +0,0 @@
-aaa

on OpenBSD

diff -ruaN a/test b/test
--- a/test	2024-03-21 11:35:38.363194916 +0000
+++ b/test	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-aaa

with GNU diffutils

--- a/test
+++ /dev/null
@@ -1 +0,0 @@
-aaa

with Busybox's diff

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

No branches or pull requests

2 participants