summaryrefslogblamecommitdiffstats
path: root/test/edit.test
blob: 98fd3931f15452d8ca3d95b7372607f475f0a5ff (plain) (tree)
1
2
3
4
5
6
7
8
9
                      
 
                                                         


                 

                                 
                 
                             

                 
                               


                      
                                      

                


            
           
                
                
                                           
                    
       

                
     
 


             

               
                           
 







                                                           
                                      



                                                       






                                                             
                                     
                        
                                         
 



                                                                
                           






                                    
                                           



                                                       






                                                          
                                    





                

          
              
$ 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
$ 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