mirror of https://gitee.com/openkylin/quilt.git
Enforce valid patch names
Allowing patch names to contain spaces would require major changes (such as the format of the series file), so we'd better detect that the user tries to use spaces in the patch name, and refuse it. Also, refuse patches named series, as it would result in awful corruptions of the internal state. Author: Martin Quinson Gbp-Pq: Name restrict-patch-names
This commit is contained in:
parent
8a43d1d0d8
commit
445cc17f17
|
@ -77,6 +77,8 @@ fi
|
|||
|
||||
new_patch=${new_patch#$QUILT_PATCHES/}
|
||||
|
||||
check_potential_patchname "$new_patch"
|
||||
|
||||
if patch_in_series $new_patch || \
|
||||
[ -d "$QUILT_PC/$new_patch" ] || \
|
||||
[ -e "$(patch_file_name $new_patch)" ]
|
||||
|
|
|
@ -186,6 +186,8 @@ do
|
|||
patch=${orig_patch_file##*/}
|
||||
fi
|
||||
|
||||
check_potential_patchname "$patch"
|
||||
|
||||
patch_file=$(find_patch_file "$orig_patch_file") || exit 1
|
||||
merged_patch_file="$patch_file"
|
||||
|
||||
|
|
|
@ -92,6 +92,8 @@ fi
|
|||
|
||||
patch=${1#$QUILT_PATCHES/}
|
||||
|
||||
check_potential_patchname "$patch"
|
||||
|
||||
if patch_in_series $patch
|
||||
then
|
||||
printf $"Patch %s exists already\n" "$(print_patch $patch)" >&2
|
||||
|
|
|
@ -77,6 +77,8 @@ patch=$(find_patch_in_series "$opt_patch") || exit 1
|
|||
|
||||
new_patch=${1#$QUILT_PATCHES/}
|
||||
|
||||
check_potential_patchname "$new_patch"
|
||||
|
||||
if patch_in_series "$new_patch" || \
|
||||
[ -d "$QUILT_PC/$new_patch" ] || \
|
||||
[ -e "$(patch_file_name "$new_patch")" ]
|
||||
|
|
|
@ -1019,6 +1019,23 @@ consistency_check()
|
|||
fi
|
||||
}
|
||||
|
||||
# We don't want patch with spaces in their name
|
||||
check_potential_patchname()
|
||||
{
|
||||
local patch="$1"
|
||||
if echo "$patch" | grep -q ' '
|
||||
then
|
||||
printf $"Patch name '%s' invalid: cannot contain spaces.\n" "$patch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$patch" = "$QUILT_SERIES" ]
|
||||
then
|
||||
printf $"No patch can be named '%s' as this would conflict with the\nseries file used internally by quilt.\n" "$QUILT_SERIES" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
print_patch()
|
||||
{
|
||||
echo "${QUILT_PATCHES_PREFIX:+$SUBDIR_DOWN$QUILT_PATCHES/}$1"
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
$ mkdir patches
|
||||
|
||||
$ quilt new "name with spaces"
|
||||
> Patch name 'name with spaces' invalid: cannot contain spaces.
|
||||
$ echo %{?}
|
||||
> 1
|
||||
|
||||
$ quilt new series
|
||||
> No patch can be named 'series' as this would conflict with the
|
||||
> series file used internally by quilt.
|
||||
$ echo %{?}
|
||||
> 1
|
||||
|
||||
|
||||
|
||||
$ echo "+toto" > patchfile
|
||||
|
||||
$ quilt import -P 'name2 with spaces' patchfile
|
||||
> Patch name 'name2 with spaces' invalid: cannot contain spaces.
|
||||
$ echo %{?}
|
||||
> 1
|
||||
|
||||
$ quilt import -P series patchfile
|
||||
> No patch can be named 'series' as this would conflict with the
|
||||
> series file used internally by quilt.
|
||||
$ echo %{?}
|
||||
> 1
|
||||
|
||||
|
||||
|
||||
$ quilt new patch1
|
||||
> Patch patches/patch1 is now on top
|
||||
|
||||
$ quilt fork "patch 1"
|
||||
> Patch name 'patch 1' invalid: cannot contain spaces.
|
||||
$ echo %{?}
|
||||
> 1
|
||||
|
||||
$ quilt fork series
|
||||
> No patch can be named 'series' as this would conflict with the
|
||||
> series file used internally by quilt.
|
||||
$ echo %{?}
|
||||
> 1
|
||||
|
||||
|
||||
|
||||
$ quilt rename "patch 1"
|
||||
> Patch name 'patch 1' invalid: cannot contain spaces.
|
||||
$ echo %{?}
|
||||
> 1
|
||||
|
||||
$ quilt rename series
|
||||
> No patch can be named 'series' as this would conflict with the
|
||||
> series file used internally by quilt.
|
||||
$ echo %{?}
|
||||
> 1
|
Loading…
Reference in New Issue