Re: [PATCH 1/3] rebase: avoid non-function use of "return" on FreeBSD
"Kyle J. McKay" <mackyle@gmail.com> writes:
> So I suggest that in the interest of fixing rebase on FreeBSD in an
> expeditious fashion, patches 1/3 and 2/3 get picked up (see note
> below) now and that the follow-on patch below, after being enhanced to
> pass all tests, be submitted separately at some future point.
> Needs-Signed-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Signed-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Show 146 quoted lines
> From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
> Subject: [PATCH 4/3] rebase: stop using . within function
>
> Move the whole run_specific_rebase_internal function to
> git-rebase--$type.
>
> The .-ed script defines the complete function, and then the
> function is used from the toplevel script.
>
> The goal is to avoid using tricky features that may trigger
> bugs on some shells.
>
> The result is simpler, just using the basic pattern:
>
> 1. use '. file' to import a set of functions
> 2. then use these functions
>
> Needs-Signed-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
> ---
> git-rebase--am.sh | 3 +--
> git-rebase--interactive.sh | 3 +--
> git-rebase--merge.sh | 3 +--
> git-rebase.sh | 40 +++++++++++++++++++++-------------------
> 4 files changed, 24 insertions(+), 25 deletions(-)
>
> diff --git a/git-rebase--am.sh b/git-rebase--am.sh
> index 2d3f6d55..b48b3e90 100644
> --- a/git-rebase--am.sh
> +++ b/git-rebase--am.sh
> @@ -4,7 +4,7 @@
> # Copyright (c) 2010 Junio C Hamano.
> #
>
> -git_rebase__am() {
> +run_specific_rebase_infile() {
> case "$action" in
> continue)
> git am --resolved --resolvemsg="$resolvemsg" &&
> @@ -75,4 +75,3 @@ git_rebase__am() {
>
> move_to_original_branch
> }
> -git_rebase__am
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index 42164f11..a7670eb0 100644
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -810,7 +810,7 @@ add_exec_commands () {
> mv "$1.new" "$1"
> }
>
> -git_rebase__interactive() {
> +run_specific_rebase_infile() {
> case "$action" in
> continue)
> # do we have anything to commit?
> @@ -1044,4 +1044,3 @@ EOF
> git update-ref ORIG_HEAD $orig_head
> do_rest
> }
> -git_rebase__interactive
> diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh
> index b5f05bf5..9550e656 100644
> --- a/git-rebase--merge.sh
> +++ b/git-rebase--merge.sh
> @@ -101,7 +101,7 @@ finish_rb_merge () {
> say All done.
> }
>
> -git_rebase__merge() {
> +run_specific_rebase_infile() {
> case "$action" in
> continue)
> read_state
> @@ -153,4 +153,3 @@ git_rebase__merge() {
>
> finish_rb_merge
> }
> -git_rebase__merge
> diff --git a/git-rebase.sh b/git-rebase.sh
> index 07e2bd48..9e105626 100755
> --- a/git-rebase.sh
> +++ b/git-rebase.sh
> @@ -175,7 +175,7 @@ run_specific_rebase () {
> export GIT_EDITOR
> autosquash=
> fi
> - . git-rebase--$type
> + run_specific_rebase_infile
> ret=$?
> if test $ret -eq 0
> then
> @@ -353,6 +353,26 @@ then
> die "$(gettext "The --edit-todo action can only be used during interactive rebase.")"
> fi
>
> +if test -n "$rebase_root" && test -z "$onto"
> +then
> + test -z "$interactive_rebase" && interactive_rebase=implied
> +fi
> +
> +if test -n "$interactive_rebase"
> +then
> + type=interactive
> + state_dir="$merge_dir"
> +elif test -n "$do_merge"
> +then
> + type=merge
> + state_dir="$merge_dir"
> +else
> + type=am
> + state_dir="$apply_dir"
> +fi
> +
> +. git-rebase--$type
> +
> case "$action" in
> continue)
> # Sanity check
> @@ -407,24 +427,6 @@ and run me again. I am stopping in case you still have something
> valuable there.')"
> fi
>
> -if test -n "$rebase_root" && test -z "$onto"
> -then
> - test -z "$interactive_rebase" && interactive_rebase=implied
> -fi
> -
> -if test -n "$interactive_rebase"
> -then
> - type=interactive
> - state_dir="$merge_dir"
> -elif test -n "$do_merge"
> -then
> - type=merge
> - state_dir="$merge_dir"
> -else
> - type=am
> - state_dir="$apply_dir"
> -fi
> -
> if test -z "$rebase_root"
> then
> case "$#" in
> --
> 1.8.5--
Matthieu Moy
http://www-verimag.imag.fr/~moy/