diff options
-rw-r--r-- | quilt/diff.in | 9 | ||||
-rw-r--r-- | quilt/refresh.in | 2 | ||||
-rw-r--r-- | quilt/scripts/patchfns.in | 6 | ||||
-rw-r--r-- | test/faildiff.test | 38 |
4 files changed, 53 insertions, 2 deletions
diff --git a/quilt/diff.in b/quilt/diff.in index 6b4f9d6..68eac9f 100644 --- a/quilt/diff.in +++ b/quilt/diff.in @@ -97,7 +97,7 @@ colorize() { do_diff() { - local file=$1 old_file=$2 new_file=$3 + local file=$1 old_file=$2 new_file=$3 status if [ -n "$opt_reverse" ] then @@ -119,6 +119,13 @@ do_diff() fi else diff_file "$file" "$old_file" "$new_file" | colorize + + # Test the return value of diff, and propagate the error if any + status=${PIPESTATUS[0]} + if [ $status != 0 ] + then + die $status + fi fi } diff --git a/quilt/refresh.in b/quilt/refresh.in index 6c6b4d0..71d34ec 100644 --- a/quilt/refresh.in +++ b/quilt/refresh.in @@ -231,7 +231,7 @@ do fi if ! diff_file "$file" "$old_file" "$new_file" then - printf $"Diff failed, aborting\n" >&2 + printf $"Diff failed on file '%s', aborting\n" "$new_file" >&2 die 1 fi diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in index c96701a..513a500 100644 --- a/quilt/scripts/patchfns.in +++ b/quilt/scripts/patchfns.in @@ -763,6 +763,12 @@ diff_file() echo "$line" cat fi + + # Test the return value of diff, and propagate the error retcode if any + if [ ${PIPESTATUS[0]} == 2 ] + then + return 1 + fi } cat_file() diff --git a/test/faildiff.test b/test/faildiff.test new file mode 100644 index 0000000..02705b5 --- /dev/null +++ b/test/faildiff.test @@ -0,0 +1,38 @@ + $ mkdir patches + + $ quilt new test.diff + > Patch %{P}test.diff is now on top + + $ cat > test.txt + < This is test.txt. + $ quilt add test.txt + > File test.txt added to patch %{P}test.diff + +What happens when diff fails because of a permission error? + + $ chmod -r test.txt + + $ quilt refresh + > diff: test.txt: Permission denied + > Diff failed on file 'test.txt', aborting + $ echo %{?} + > 1 + + $ chmod +r test.txt + +What happens on binary files? + + $ printf "\\002\\000\\001" > test.bin + $ quilt add test.bin + > File test.bin added to patch %{P}test.diff + + $ printf "\\003\\000\\001" > test.bin + $ quilt diff -pab --no-index + >~ (Files|Binary files) a/test\.bin and b/test\.bin differ + $ echo %{?} + > 1 + + $ quilt refresh + > Diff failed on file 'test.bin', aborting + $ echo %{?} + > 1 |