SHA256
1
0
forked from pool/quilt
quilt/edit-03-fix-corner-case.patch
Jean Delvare 6c57f63fdf Translation fixes:
- translation-fixes-01.patch: Make gettext happy (needed so that
  following patches apply cleanly.)
- translation-fixes-02.patch: Missing escape in Japanese
  translation.
- translation-fixes-03.patch: Improve the German translation
  (including a number of important fixes.)
- translation-fixes-04.patch: Fix translation of main usage message
  (all languages.)
Fixes to the "edit" command:
- edit-01-test-file-creation.patch: edit: Improve the test case
  (needed so that following patches apply cleanly.)
- edit-02-call-remove-not-revert.patch: edit: Use command "remove"
  to remove files.
- edit-03-fix-corner-case.patch: edit: Fix a corner case.

OBS-URL: https://build.opensuse.org/package/show/devel:tools:scm/quilt?expand=0&rev=100
2015-02-16 16:29:50 +00:00

92 lines
2.6 KiB
Diff

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