1#!/bin/sh
2
3do_filename() {
4 desc=$1
5 postimage=$2
6
7 rm -fr file-creation &&
8 git init file-creation &&
9 (
10 cd file-creation &&
11 git commit --allow-empty -m init &&
12 echo postimage >"$postimage" &&
13 git add -N "$postimage" &&
14 git diff HEAD >"../git-$desc.diff"
15 ) &&
16
17 rm -fr trad-modification &&
18 mkdir trad-modification &&
19 (
20 cd trad-modification &&
21 echo preimage >"$postimage.orig" &&
22 echo postimage >"$postimage" &&
23 ! diff -u "$postimage.orig" "$postimage" >"../diff-$desc.diff"
24 ) &&
25
26 rm -fr trad-creation &&
27 mkdir trad-creation &&
28 (
29 cd trad-creation &&
30 mkdir a b &&
31 echo postimage >"b/$postimage" &&
32 ! diff -pruN a b >"../add-$desc.diff"
33 )
34}
35
36do_filename plain postimage.txt &&
37do_filename 'with spaces' 'post image.txt' &&
38do_filename 'with tab' 'post image.txt' &&
39do_filename 'with backslash' 'post\image.txt' &&
40do_filename 'with quote' '"postimage".txt' &&
41expand add-plain.diff >damaged.diff ||
42{
43 echo >&2 Failed. &&
44 exit 1
45}