Skip to content

Instantly share code, notes, and snippets.

@r1walz r1walz/cmds.sh
Created Jun 25, 2019

Embed
What would you like to do?
Setup to check the workings of apply's ignore-whitespace
# already on master
$ git apply patch2.patch --ignore-whitespace
#!/bin/bash
if test -d /tmp/tmp
then
rm -rf /tmp/tmp
fi
mkdir /tmp/tmp
pushd /tmp/tmp
cat >patch1.patch <<EOF
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..85311c8
--- /dev/null
+++ b/main.c
@@ -0,0 +1,28 @@
+Lorem Ipsum is simply dummy text of the printing and typesetting industry.
+Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
+when an unknown printer took a galley of type and scrambled it to make a type
+specimen book. It has survived not only five centuries, but also the leap into
+electronic typesetting, remaining essentially unchanged. It was popularised in
+the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
+and more recently with desktop publishing software like Aldus PageMaker
+including versions of Lorem Ipsum.
+
+It is a long established fact that a reader will be distracted by the readable
+content of a page when looking at its layout. The point of using Lorem Ipsum is
+that it has a more-or-less normal distribution of letters, as opposed to using
+'Content here, content here', making it look like readable English. Many
+desktop publishing packages and web page editors now use Lorem Ipsum as their
+default model text, and a search for 'lorem ipsum' will uncover many web sites
+still in their infancy. Various versions have evolved over the years, sometimes
+by accident, sometimes on purpose (injected humour and the like).
+
+Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots
+in a piece of classical Latin literature from 45 BC, making it over 2000 years
+old. Richard McClintock, a Latin professor at Hampden-Sydney College in
+Virginia, looked up one of the more obscure Latin words, consectetur, from a
+Lorem Ipsum passage, and going through the cites of the word in classical
+literature, discovered the undoubtable source. Lorem Ipsum comes from sections
+1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good
+and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of
+ethics, very popular during the Renaissance. The first line of Lorem Ipsum,
+"Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
EOF
sed -e 's/Z/ /g' >patch2.patch <<EOF
diff --git a/main.c b/main.c
index 85311c8..eb5a4d7 100644
--- a/main.c
+++ b/main.c
@@ -7,14 +7,16 @@ the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
Zand more recently with desktop publishing software like Aldus PageMaker
Zincluding versions of Lorem Ipsum.
Z
-It is a long established fact that a reader will be distracted by the readable
-content of a page when looking at its layout. The point of using Lorem Ipsum is
-that it has a more-or-less normal distribution of letters, as opposed to using
-'Content here, content here', making it look like readable English. Many
-desktop publishing packages and web page editors now use Lorem Ipsum as their
-default model text, and a search for 'lorem ipsum' will uncover many web sites
-still in their infancy. Various versions have evolved over the years, sometimes
-by accident, sometimes on purpose (injected humour and the like).
+There are many variations of passages of Lorem Ipsum available, but the
+majority have suffered alteration in some form, by injected humour, or
+randomised words which don't look even slightly believable. If you are going to
+use a passage of Lorem Ipsum, you need to be sure there isn't anything
+embarrassing hidden in the middle of text. All the Lorem Ipsum generators on
+the Internet tend to repeat predefined chunks as necessary, making this the
+first true generator on the Internet. It uses a dictionary of over 200 Latin
+words, combined with a handful of model sentence structures, to generate Lorem
+Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always
+free from repetition, injected humour, or non-characteristic words etc.
Z
ZContrary to popular belief, Lorem Ipsum is not simply random text. It has roots
Zin a piece of classical Latin literature from 45 BC, making it over 2000 years
EOF
cat >patch3.patch <<EOF
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..85311c8
--- /dev/null
+++ b/main.c
@@ -0,0 +1,28 @@
+Lorem Ipsum is simply dummy text of the printing and typesetting industry.
+Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
+when an unknown printer took a galley of type and scrambled it to make a type
+specimen book. It has survived not only five centuries, but also the leap into
+electronic typesetting, remaining essentially unchanged. It was popularised in
+the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
+and more recently with desktop publishing software like Aldus PageMaker
+including versions of Lorem Ipsum.
+
+ It is a long established fact that a reader will be distracted by the readable
+ content of a page when looking at its layout. The point of using Lorem Ipsum is
+ that it has a more-or-less normal distribution of letters, as opposed to using
+ 'Content here, content here', making it look like readable English. Many
+ desktop publishing packages and web page editors now use Lorem Ipsum as their
+ default model text, and a search for 'lorem ipsum' will uncover many web sites
+ still in their infancy. Various versions have evolved over the years, sometimes
+ by accident, sometimes on purpose (injected humour and the like).
+
+Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots
+in a piece of classical Latin literature from 45 BC, making it over 2000 years
+old. Richard McClintock, a Latin professor at Hampden-Sydney College in
+Virginia, looked up one of the more obscure Latin words, consectetur, from a
+Lorem Ipsum passage, and going through the cites of the word in classical
+literature, discovered the undoubtable source. Lorem Ipsum comes from sections
+1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good
+and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of
+ethics, very popular during the Renaissance. The first line of Lorem Ipsum,
+"Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
EOF
git init
echo '*.patch' >.gitignore
git add .gitignore
git commit -m 'initial'
git checkout -b topic
git apply patch1.patch
git add main.c
git commit -m 'p1'
git apply patch2.patch
git commit -am 'p2'
git checkout master
git apply patch3.patch
git add main.c
git commit -m 'p3'
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.