--- oslo-series-v3/v3-0014-Use-git-check-ref-format-to-validate-patch-names.patch +++ oslo-series-v4/v4-0014-Use-git-check-ref-format-to-validate-patch-names.patch @@ -1,32 +1,30 @@ -From 460853e6e31a20258680b5a2e5d6c89a7415fdec Mon Sep 17 00:00:00 2001 +From dad37836c39986d0307221e2c28feb80da92a3f1 Mon Sep 17 00:00:00 2001 From: Per Cederqvist -Date: Fri, 16 May 2014 11:53:29 +0200 -Subject: [GUILT v3 14/31] Use "git check-ref-format" to validate patch names. +Date: Sun, 18 May 2014 21:24:35 +0200 +Subject: [GUILT v4 14/33] Use "git check-ref-format" to validate patch names. To: Jeff Sipek Cc: git@vger.kernel.org The valid_patchname now lets "git check-ref-format" do its job instead of trying (and failing) to implement the same rules. See -git-check-ref-format(1) for a list of the rules. +git-check-ref-format(1) for a list of the rules. Re-implement rules +added to "git check-ref-format" after Git 1.5.0, so that guilt rejects +the same names no matter what version of Git we are using (but +versions prior to 1.5.0 are not supported). Refer to the git-check-ref-format(1) man page in the error messages produced when valid_patchname indicates that the name is bad. Added testcases that breaks most of the rules in that man-page. -Git version 1.8.5 no longer allows the single character "@" as a -branch name. Guilt always rejects that name, for increased -compatibility. - Signed-off-by: Per Cederqvist -Signed-off-by: Josef 'Jeff' Sipek --- - guilt | 21 ++- + guilt | 46 +++++- guilt-fork | 2 +- guilt-import | 2 +- guilt-new | 2 +- regression/t-025.out | 426 +++++++++++++++++++++++++++++++++++++++++++++++++-- regression/t-025.sh | 12 +- regression/t-032.out | 4 +- - 7 files changed, 446 insertions(+), 23 deletions(-) + 7 files changed, 474 insertions(+), 20 deletions(-) diff --git a/guilt b/guilt index 3fc524e..23cc2da 100755 --- a/guilt +++ b/guilt - @@ -132,14 +132,19 @@ fi + @@ -132,14 +132,50 @@ fi # usage: valid_patchname valid_patchname() { - - case "$1" in + + # Once we only support Git 1.7.8 and newer, the command below + + # could be replaced with: + + # + + # git check-ref-format --allow-onelevel "$1" + + # + + # Instead, we arbitrarily prepend one level. The result + + # should be the same, and this is portable to all existing + + # versions of Git. + + git check-ref-format a/"$1" + + if [ $? -ne 0 ]; then + + return 1 + + fi + + + + # We want to reject all names that Git 2.0.0 rejects. In case + + # we are running an older version, we explicitly check some + + # cases that were added to Git after version 1.5.0. This code + + # aims to support Git version 1.5.0 and newer. + + + + # Git 1.7.6.4 and newer rejects the DEL character. + + if [ `echo "$1"|tr -d '\177'` != "$1" ]; then + + return 1 + + fi + + + + # Git 1.7.8 and newer rejects refs that start or end with + + # slash or contain multiple adjacent slashes. + case "$1" in - /*|./*|../*|*/./*|*/../*|*/.|*/..|*/|*\ *|*\ *) - - return 1;; + + /*|*/|*//*) + return 1;; - *:*) - return 1;; - *) - return 0;; - - esac - + if git check-ref-format --allow-onelevel "$1"; then - + # Starting with Git version 1.8.5, a branch cannot be - + # the single character "@". Make sure guilt rejects - + # that name even if we are currently using an older - + # version of Git. This ensures that the test suite - + # runs fine using any version of Git. - + if [ "$1" = "@" ]; then - + return 1 - + fi - + return 0 - + else + esac + + + + # Git 1.7.8 and newer rejects refname components that end in + + # .lock. + + case "$1" in + + *.lock/*|*.lock) + + return 1;; + + esac + + + + # Git 1.8.5 and newer rejects refnames that are made up of the + + # single character "@". + + if [ "$1" = "@" ]; then + return 1 + fi + + + + return 0 } get_branch()