quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH] diff, refresh: accept file name with spaces


From: Jean Delvare
Subject: [Quilt-dev] [PATCH] diff, refresh: accept file name with spaces
Date: Fri, 18 Mar 2011 15:37:02 +0100
User-agent: KMail/1.12.4 (Linux/2.6.32.29-0.3-pae; KDE/4.3.5; i686; ; )

This is a continuation of Yasushi SHOJI's initial work fixing support
for file name with spaces. This time I fixed support in the diff and
refresh commands, two commands which are frequently used. As before,
no guarantee is made that all options are covered.

Signed-off-by: Jean Delvare <address@hidden>
Cc: Yasushi SHOJI <address@hidden>
---
 quilt/diff.in                |   20 +++++++++++++-------
 quilt/refresh.in             |   14 ++++++++++----
 test/space-in-filenames.test |   22 ++++++++++++++++++++++
 3 files changed, 45 insertions(+), 11 deletions(-)

--- a/test/space-in-filenames.test
+++ b/test/space-in-filenames.test
@@ -10,6 +10,7 @@ $ quilt add foo
 $ quilt files
 > foo
 
+$ echo foo > "foo bar"
 $ quilt add "foo bar"
 > File foo bar added to patch patches/test.diff
 
@@ -17,6 +18,27 @@ $ quilt files
 > foo
 > foo bar
 
+$ echo bar > "foo bar"
+$ quilt diff -p ab
+> Index: b/foo bar
+> ===================================================================
+> --- a/foo bar
+> +++ b/foo bar
+> @@ -1 +1 @@
+> -foo
+> +bar
+
+$ quilt refresh -p ab
+> Refreshed patch patches/test.diff
+$ cat patches/test.diff
+> Index: b/foo bar
+> ===================================================================
+> --- a/foo bar
+> +++ b/foo bar
+> @@ -1 +1 @@
+> -foo
+> +bar
+
 $ quilt add "a: b [c]"
 > File a: b [c] added to patch patches/test.diff
 
--- a/quilt/diff.in
+++ b/quilt/diff.in
@@ -110,15 +110,15 @@ do_diff()
        then
                [ -s "$old_file" ] || old_file=/dev/null
                [ -s "$new_file" ] || new_file=/dev/null
-               if ! diff -q $old_file $new_file >/dev/null
+               if ! diff -q "$old_file" "$new_file" >/dev/null
                then
                        export LANG=$ORIGINAL_LANG
-                       $opt_diff $old_file $new_file
+                       $opt_diff "$old_file" "$new_file"
                        export LANG=POSIX
                        true
                fi
        else
-               diff_file $file $old_file $new_file | colorize
+               diff_file "$file" "$old_file" "$new_file" | colorize
        fi
 }
 
@@ -281,6 +281,10 @@ else
        patches=( $last_patch )
 fi
 
+# Properly handle spaces in file names
+saved_IFS=$IFS
+IFS=$'\n'
+
 for patch in address@hidden
 do
        for file in $(files_in_patch_ordered $patch)
@@ -310,6 +314,8 @@ else
        files=( $(sort -u $tmp_files) )
 fi
 
+IFS=$saved_IFS
+
 if [ -n "$opt_relative" ]
 then
        workdir=$(gen_tempfile -d $PWD/quilt)
@@ -328,22 +334,22 @@ do
        then
                old_file="$workdir/$file"
        else
-               patch="$(first_modified_by $file address@hidden)"
+               patch="$(first_modified_by "$file" address@hidden)"
                if [ -z "$patch" ]
                then
                        [ -z "$opt_snapshot" ] \
                        && printf $"File %s is not being modified\n" "$file" >&2
                        continue
                fi
-               old_file="$(backup_file_name $patch $file)"
+               old_file="$(backup_file_name $patch "$file")"
        fi
 
-       next_patch=$(next_patch_for_file $last_patch $file)
+       next_patch=$(next_patch_for_file $last_patch "$file")
        if [ -z "$next_patch" ]
        then
                new_file="$file"
        else
-               new_file="$(backup_file_name $next_patch $file)"
+               new_file="$(backup_file_name $next_patch "$file")"
                files_were_shadowed=1
        fi
 
--- a/quilt/refresh.in
+++ b/quilt/refresh.in
@@ -153,6 +153,10 @@ QUILT_DIFF_OPTS="$QUILT_DIFF_OPTS $opt_f
 
 patch=$(find_applied_patch "$1") || exit 1
 
+# Properly handle spaces in file names
+saved_IFS=$IFS
+IFS=$'\n'
+
 if [ -z "$opt_sort" ]
 then
        files=( $(files_in_patch_ordered $patch) )
@@ -160,6 +164,8 @@ else
        files=( $(files_in_patch $patch | sort) )
 fi
 
+IFS=$saved_IFS
+
 if [ -n "$opt_fork" -a $# -ne 0 ]
 then
        printf $"Can only refresh the topmost patch with -z currently\n" >&2
@@ -213,17 +219,17 @@ do
                old_file=$workdir/$file
                new_file=$file
        else
-               old_file=$(backup_file_name $patch $file)
-               next_patch=$(next_patch_for_file $patch $file)
+               old_file=$(backup_file_name $patch "$file")
+               next_patch=$(next_patch_for_file $patch "$file")
                if [ -z "$next_patch" ]
                then
                        new_file=$file
                else
-                       new_file=$(backup_file_name $next_patch $file)
+                       new_file=$(backup_file_name $next_patch "$file")
                        files_were_shadowed=1
                fi
        fi
-       if ! diff_file $file $old_file $new_file
+       if ! diff_file "$file" "$old_file" "$new_file"
        then
                printf $"Diff failed, aborting\n" >&2
                die 1

-- 
Jean Delvare
Suse L3



reply via email to

[Prev in Thread] Current Thread [Next in Thread]