3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description
='add -e basic tests'
11 LO, praise of the prowess of people-kings
12 of spear-armed Danes, in days long sped,
13 we have heard, and what honor the athelings won!
14 Oft Scyld the Scefing from squadroned foes,
15 from many a tribe, the mead-bench tore,
16 awing the earls. Since erst he lay
17 friendless, a foundling, fate repaid him:
18 for he waxed under welkin, in wealth he throve,
19 till before him the folk, both far and near,
20 who house by the whale-path, heard his mandate,
21 gave him gifts: a good king he!
24 test_expect_success
'setup' '
28 git commit -m initial file
32 cat > expected-patch
<< EOF
33 diff --git a/file b/file
34 index b9834b5..0b8f197 100644
38 -LO, praise of the prowess of people-kings
39 -of spear-armed Danes, in days long sped,
40 -we have heard, and what honor the athelings won!
41 -Oft Scyld the Scefing from squadroned foes,
42 -from many a tribe, the mead-bench tore,
43 -awing the earls. Since erst he lay
44 -friendless, a foundling, fate repaid him:
45 -for he waxed under welkin, in wealth he throve,
46 -till before him the folk, both far and near,
47 -who house by the whale-path, heard his mandate,
48 -gave him gifts: a good king he!
50 +mv -f "\$1" orig-patch &&
55 diff --git a/file b/file
56 index b9834b5..ef6e94c 100644
59 @@ -3,1 +3,333 @@ of spear-armed Danes, in days long sped,
60 we have heard, and what honor the athelings won!
62 Oft Scyld the Scefing from squadroned foes,
63 @@ -2,7 +1,5 @@ awing the earls. Since erst he lay
64 friendless, a foundling, fate repaid him:
66 for he waxed under welkin, in wealth he throve,
70 diff --git a/file b/file
71 index b9834b5..ef6e94c 100644
75 LO, praise of the prowess of people-kings
76 of spear-armed Danes, in days long sped,
77 we have heard, and what honor the athelings won!
79 Oft Scyld the Scefing from squadroned foes,
80 from many a tribe, the mead-bench tore,
81 awing the earls. Since erst he lay
82 friendless, a foundling, fate repaid him:
84 for he waxed under welkin, in wealth he throve,
85 till before him the folk, both far and near,
86 who house by the whale-path, heard his mandate,
89 echo "#!$SHELL_PATH" >fake-editor.sh
90 cat >> fake-editor.sh
<<\EOF
91 mv -f "$1" orig-patch
&&
95 test_set_editor
"$(pwd)/fake-editor.sh"
96 chmod a
+x fake-editor.sh
98 test_expect_success
'add -e' '
100 cp fake-editor.sh file &&
102 test_cmp fake-editor.sh file &&
103 test_cmp orig-patch expected-patch &&
104 git diff --cached > out &&
105 test_cmp out expected