git-legacy-rebase: simplify unnecessary triply-nested if

The git-legacy-rebase.sh script previously had code of the form: if git_am_opt: if interactive: if incompatible_opts: show_error_about_interactive_and_am_incompatibilities if rebase-merge: if incompatible_opts show_error_about_merge_and_am_incompatibilities which was a triply nested if. However, the first conditional (git_am_opt) and third (incompatible_opts) were somewhat redundant: the latter condition was a strict subset of the former. Simplify this by moving the innermost conditional to the outside, allowing us to remove the test on git_am_opt entirely and giving us the following form: if incompatible_opts: if interactive: show_error_about_interactive_and_am_incompatibilities if rebase-merge: show_error_about_merge_and_am_incompatibilities Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Dec 11, 2018 at 08:11 UTC 7b76ac664cbe68c64bf79bd37e8b5d5fe690ba29
1 file changed +8 -12
git-legacy-rebase.sh
+8 -12
@@ -501,21 +501,17 @@ then
501 git_format_patch_opt="$git_format_patch_opt --progress"
502 fi
503
504 -if test -n "$git_am_opt"; then
505 - incompatible_opts=$(echo " $git_am_opt " | \
506 - sed -e 's/ -q / /g' -e 's/^ \(.*\) $/\1/')
504 +incompatible_opts=$(echo " $git_am_opt " | \
505 + sed -e 's/ -q / /g' -e 's/^ \(.*\) $/\1/')
506 +if test -n "$incompatible_opts"
507 +then
508 if test -n "$interactive_rebase"
509 then
509 - if test -n "$incompatible_opts"
510 - then
511 - die "$(gettext "fatal: cannot combine am options with interactive options")"
512 - fi
510 + die "$(gettext "fatal: cannot combine am options with interactive options")"
511 fi
514 - if test -n "$do_merge"; then
515 - if test -n "$incompatible_opts"
516 - then
517 - die "$(gettext "fatal: cannot combine am options with merge options")"
518 - fi
512 + if test -n "$do_merge"
513 + then
514 + die "$(gettext "fatal: cannot combine am options with merge options")"
515 fi
516 fi
517