1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
$ mkdir patches subdir
# Test the behavior if the editor modifies existing files
$ cat > editor
< #! /bin/sh
< echo Editing $1
< sed -e 's:foo:bar:' $1 > $1.new
< mv $1.new $1
$ chmod +x editor
$ unset VISUAL
$ export EDITOR=%{PWD}/editor
$ quilt new patch
> Patch %{P}patch is now on top
$ echo foobar > foobar
$ quilt edit foobar
> File foobar added to patch %{P}patch
> Editing foobar
$ cat foobar
> barbar
$ cd subdir
$ echo foo > foo
$ quilt edit foo
> File subdir/foo added to patch %{_P}patch
> Editing subdir/foo
$ cd ..
$ cat subdir/foo
> bar
$ quilt files
> foobar
> subdir/foo
$ quilt refresh
> Refreshed patch %{P}patch
# Test the behavior if the editor deletes a file completely
$ echo foobaz > foobaz
$ cat > editor
< #! /bin/sh
< echo Deleting $1
< rm -f $1
$ quilt edit foobaz
> File foobaz added to patch %{P}patch
> Deleting foobaz
$ [ ! -e foobaz ] || echo "File foobaz shouldn't exist"
# Test the behavior if the editor is called on a new file but
# does not actually create it
$ cat > editor
< #! /bin/sh
< echo Doing nothing to $1
$ quilt edit nofoo
> File nofoo added to patch %{P}patch
> Doing nothing to nofoo
> File nofoo removed from patch %{P}patch
# Test the behavior if the patch is deleting a file and the
# user calls "quilt edit" on that file but makes no change to it
$ rm -f foobar
$ quilt refresh
> Refreshed patch %{P}patch
$ quilt diff -p ab --no-index foobar
> --- a/foobar
> +++ /dev/null
> @@ -1 +0,0 @@
> -foobar
$ quilt edit foobar
> File foobar is already in patch %{P}patch
> Doing nothing to foobar
$ [ ! -e foobar ] || echo "File foobar shouldn't exist"
# Test the behavior if the editor creates a brand new file
$ cat > editor
< #! /bin/sh
< echo Creating $1
< echo "new line" > $1
$ quilt edit foo2
> File foo2 added to patch %{P}patch
> Creating foo2
$ cat foo2
> new line
$ quilt files -v
> + foo2
> - foobar
> - foobaz
> subdir/foo
|