Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.2
quilt
edit-03-fix-corner-case.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File edit-03-fix-corner-case.patch of Package quilt
From: Jean Delvare <jdelvare@suse.de> Subject: edit: Fix a corner case Upstream: Submitted (2011-02-11) There is one corner case which is not properly handled by the "edit" command. If a patch deletes a file, and the user calls "quilt edit" on that file but does not actually add anything back to it, "quilt remove" is called on the file when the editor exits. This causes the file to be restored to its original state before the patch deleted it. The user never asked for that, so the file should be left to its deleted state in this case. The file must only be removed from the patch if it was not part of the patch originally. The same problem would occur if the editor deleted the file. In general text editors don't do that, they'd leave an empty file instead, but nothing prevents them from actually deleting the file so we should handle this case properly too. --- quilt/edit.in | 4 +++- test/edit.test | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) --- a/quilt/edit.in +++ b/quilt/edit.in @@ -67,9 +67,11 @@ then fi LANG=$ORIGINAL_LANG $EDITOR "${@/#/$SUBDIR}" status=$? + +patch=$(top_patch) for file in "$@" do - if ! [ -e "$SUBDIR$file" ] + if [ ! -e "$SUBDIR$file" -a ! -s "$QUILT_PC/$patch/$file" ] then quilt_command remove "$file" status=1 --- a/test/edit.test +++ b/test/edit.test @@ -37,6 +37,19 @@ $ quilt files $ quilt refresh > Refreshed patch patches/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 patches/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 @@ -48,6 +61,23 @@ $ quilt edit nofoo > Doing nothing to nofoo > File nofoo removed from patch patches/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 patches/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 patches/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 @@ -62,5 +92,6 @@ $ cat foo2 $ quilt files -v > + foo2 -> foobar +> - foobar +> - foobaz > subdir/foo
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor