Skip to content

Commit 7b76ac6

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 899b49c commit 7b76ac6

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

git-legacy-rebase.sh

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -501,21 +501,17 @@ then
501501
git_format_patch_opt="$git_format_patch_opt --progress"
502502
fi
503503

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
507508
if test -n "$interactive_rebase"
508509
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")"
513511
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")"
519515
fi
520516
fi
521517

0 commit comments

Comments
 (0)