diff mbox series

[1/1] legacy-rebase: backport -C<n> and --whitespace=<option> checks

Message ID 84e65a4efb3d58ca777cd59c52fe86d63060ea9e.1542744118.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series legacy-rebase: fix "regression" | expand

Commit Message

Linus Arver via GitGitGadget Nov. 20, 2018, 8:02 p.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

Since 04519d720114 (rebase: validate -C<n> and --whitespace=<mode>
parameters early, 2018-11-14), the built-in rebase validates the -C and
--whitespace arguments early. As this commit also introduced a
regression test for this, and as a later commit introduced the
GIT_TEST_REBASE_USE_BUILTIN mode to run tests, we now have a
"regression" in the scripted version of `git rebase` on our hands.

Backport the validation to fix this.

Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 git-legacy-rebase.sh | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Carlo Marcelo Arenas Belón Nov. 20, 2018, 11:45 p.m. UTC | #1
Tested-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>

the C version prepends: "fatal: " unlike the shell version for both
error messages

Carlo
Junio C Hamano Nov. 21, 2018, 4:40 a.m. UTC | #2
Carlo Arenas <carenas@gmail.com> writes:

> Tested-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
>
> the C version prepends: "fatal: " unlike the shell version for both
> error messages

In addition, "Invalid whitespace option" says 'bad', not
'--whitespace=bad', in the builtin version.

I think the following would address both issues.


 git-legacy-rebase.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-legacy-rebase.sh b/git-legacy-rebase.sh
index ced0635326..b97ffdc9dd 100755
--- a/git-legacy-rebase.sh
+++ b/git-legacy-rebase.sh
@@ -340,7 +340,7 @@ do
 		warn|nowarn|error|error-all)
 			;; # okay, known whitespace option
 		*)
-			die "Invalid whitespace option: '${1%*=}'"
+			die "fatal: Invalid whitespace option: '${1#*=}'"
 			;;
 		esac
 		;;
@@ -358,7 +358,7 @@ do
 		force_rebase=t
 		;;
 	-C*[!0-9]*)
-		die "switch \`C' expects a numerical value"
+		die "fatal: switch \`C' expects a numerical value"
 		;;
 	-C*)
 		git_am_opt="$git_am_opt $1"
Johannes Schindelin Nov. 21, 2018, 2:06 p.m. UTC | #3
Hi Junio,

On Wed, 21 Nov 2018, Junio C Hamano wrote:

> Carlo Arenas <carenas@gmail.com> writes:
> 
> > Tested-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> >
> > the C version prepends: "fatal: " unlike the shell version for both
> > error messages
> 
> In addition, "Invalid whitespace option" says 'bad', not
> '--whitespace=bad', in the builtin version.
> 
> I think the following would address both issues.

Yes! Thank you. Can you squash it in?

Thanks,
Dscho

> 
> 
>  git-legacy-rebase.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/git-legacy-rebase.sh b/git-legacy-rebase.sh
> index ced0635326..b97ffdc9dd 100755
> --- a/git-legacy-rebase.sh
> +++ b/git-legacy-rebase.sh
> @@ -340,7 +340,7 @@ do
>  		warn|nowarn|error|error-all)
>  			;; # okay, known whitespace option
>  		*)
> -			die "Invalid whitespace option: '${1%*=}'"
> +			die "fatal: Invalid whitespace option: '${1#*=}'"
>  			;;
>  		esac
>  		;;
> @@ -358,7 +358,7 @@ do
>  		force_rebase=t
>  		;;
>  	-C*[!0-9]*)
> -		die "switch \`C' expects a numerical value"
> +		die "fatal: switch \`C' expects a numerical value"
>  		;;
>  	-C*)
>  		git_am_opt="$git_am_opt $1"
> 
> 
>
diff mbox series

Patch

diff --git a/git-legacy-rebase.sh b/git-legacy-rebase.sh
index 75a08b2683..ced0635326 100755
--- a/git-legacy-rebase.sh
+++ b/git-legacy-rebase.sh
@@ -337,6 +337,11 @@  do
 		fix|strip)
 			force_rebase=t
 			;;
+		warn|nowarn|error|error-all)
+			;; # okay, known whitespace option
+		*)
+			die "Invalid whitespace option: '${1%*=}'"
+			;;
 		esac
 		;;
 	--ignore-whitespace)
@@ -352,6 +357,9 @@  do
 		git_am_opt="$git_am_opt $1"
 		force_rebase=t
 		;;
+	-C*[!0-9]*)
+		die "switch \`C' expects a numerical value"
+		;;
 	-C*)
 		git_am_opt="$git_am_opt $1"
 		;;