Fix import of relative patches. This closes bug #35244. --- quilt/import.in | 8 ++++---- quilt/scripts/patchfns.in | 17 ++++++++++++++--- test/import.test | 9 +++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) --- a/test/import.test +++ b/test/import.test @@ -246,3 +246,12 @@ $ cat patches/series > patch1.diff > patchR.diff + +# Also test importing when in a subdirectory + $ touch empty.patch + $ cd t + $ touch empty2.patch + $ quilt import ../empty.patch + > Importing patch ../empty.patch (stored as ../patches/empty.patch) + $ quilt import %{PWD}/empty2.patch + > Importing patch %{PWD}/empty2.patch (stored as ../patches/empty2.patch) --- a/quilt/import.in +++ b/quilt/import.in @@ -152,16 +152,16 @@ then fi before=$(patch_after "$(top_patch)") -for patch_file in "$@" +for orig_patch_file in "$@" do if [ -n "$opt_patch" ] then patch=$opt_patch else - patch=${patch_file##*/} + patch=${orig_patch_file##*/} fi - patch_file=$(find_patch_file "$patch_file") || exit 1 + patch_file=$(find_patch_file "$orig_patch_file") || exit 1 merged_patch_file="$patch_file" if is_applied $patch @@ -199,7 +199,7 @@ do printf $"Importing patch %s\n" "$(print_patch $patch)" else printf $"Importing patch %s (stored as %s)\n" \ - "$patch_file" \ + "$orig_patch_file" \ "$(print_patch $patch)" mkdir -p "${dest%/*}" --- a/quilt/scripts/patchfns.in +++ b/quilt/scripts/patchfns.in @@ -641,10 +641,21 @@ find_patch_file() { local name="$1" - if [ -r "$name" ] + if [ ${name:0:1} = / ] then - echo "$name" - return + # Patch has absolute path + if [ -r "$name" ] + then + echo "$name" + return + fi + else + # Patch has a relative path + if [ -r "$SUBDIR$name" ] + then + echo "$SUBDIR$name" + return + fi fi local patch