mathiasbynens / small

Smallest possible syntactically valid files of different types
https://mathiasbynens.be/notes/minimal-html
1.93k stars 184 forks source link

Add diff #122

Open davidak opened 3 years ago

davidak commented 3 years ago

i thought what the smallest possible (git) diff would be

the answer would fit greatly in this repo

TPS commented 3 years ago

Solved via #123 merge?

davidak commented 3 years ago

I think we can also add a .diff file.

davidak commented 3 years ago

Some research:

I created a patch from the empty commit (https://github.com/mathiasbynens/small/commit/63a7f20c7b442c21bd9b6d4a80fdbea77e59dc6b) which resulted in an empty file. I tried to apply it, but got an error. So that is not a valid patch.

[davidak@gaming:~/code/small]$ git format-patch dfbd9249a766f67e1a142b2becd41dcb1f8b3447
0001-Add-smallest-possible-git-commit-empty.patch
0002-Add-link-to-smallest-git-commit.patch

[davidak@gaming:~/code/small]$ cat 0001-Add-smallest-possible-git-commit-empty.patch

[davidak@gaming:~/code/small]$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

[davidak@gaming:~/code/small]$ git checkout -b test
Switched to a new branch 'test'

[davidak@gaming:~/code/small]$ git am 0001-Add-smallest-possible-git-commit-empty.patch
Patch format detection failed.

So i actually changed a file with a short name ('c.c') by adding one character.

[davidak@gaming:~/code/small]$ git diff > c.patch

[davidak@gaming:~/code/small]$ cat c.patch
diff --git a/c.c b/c.c
index f7fb591..c61f0be 100644
--- a/c.c
+++ b/c.c
@@ -1 +1 @@
-int main;
+lint main;

[davidak@gaming:~/code/small]$ git diff --no-prefix > c.patch

[davidak@gaming:~/code/small]$ cat c.patch
diff --git c.c c.c
index f7fb591..c61f0be 100644
--- c.c
+++ c.c
@@ -1 +1 @@
-int main;
+lint main;

The patch can be sucessfully applied with: patch -p0 < c.patch