diff options
-rw-r--r-- | quilt.changes | 5 | ||||
-rw-r--r-- | quilt/diff.in | 20 | ||||
-rw-r--r-- | quilt/refresh.in | 14 | ||||
-rw-r--r-- | test/space-in-filenames.test | 52 |
4 files changed, 80 insertions, 11 deletions
diff --git a/quilt.changes b/quilt.changes index dc0a981..cfc70df 100644 --- a/quilt.changes +++ b/quilt.changes @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Fri Mar 25 18:47:53 CET 2011 - jdelvare@suse.de + +- quilt/diff.in, quilt/refresh.in: Accept file names with spaces. + +------------------------------------------------------------------- Fri Mar 18 12:05:33 CET 2011 - jdelvare@suse.de - test/run: Enforce single variable substitution method. There is diff --git a/quilt/diff.in b/quilt/diff.in index 1807b86..24b9761 100644 --- 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 ${patches[@]} 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 ${patches[@]})" + patch=$(first_modified_by "$file" "${patches[@]}") 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 diff --git a/quilt/refresh.in b/quilt/refresh.in index f108892..1b9071b 100644 --- a/quilt/refresh.in +++ b/quilt/refresh.in @@ -153,6 +153,10 @@ QUILT_DIFF_OPTS="$QUILT_DIFF_OPTS $opt_format" 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 diff --git a/test/space-in-filenames.test b/test/space-in-filenames.test index 335877a..eb0d035 100644 --- 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 @@ -25,6 +26,57 @@ $ quilt files > foo > foo bar +$ echo bar > "foo bar" +$ echo "new line" > "a: b [c]" +$ quilt diff -p ab +> Index: b/a: b [c] +> =================================================================== +> --- /dev/null +> +++ b/a: b [c] +> @@ -0,0 +1 @@ +> +new line +> 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/a: b [c] +> =================================================================== +> --- /dev/null +> +++ b/a: b [c] +> @@ -0,0 +1 @@ +> +new line +> Index: b/foo bar +> =================================================================== +> --- a/foo bar +> +++ b/foo bar +> @@ -1 +1 @@ +> -foo +> +bar + +$ quilt refresh -p ab --sort +> Patch patches/test.diff is unchanged +$ cat patches/test.diff +> Index: b/a: b [c] +> =================================================================== +> --- /dev/null +> +++ b/a: b [c] +> @@ -0,0 +1 @@ +> +new line +> Index: b/foo bar +> =================================================================== +> --- a/foo bar +> +++ b/foo bar +> @@ -1 +1 @@ +> -foo +> +bar + $quilt remove "a: b [c]" > File a: b [c] removed from patch patches/test.diff |