Re: [PATCH] rebase -i: Remember merge options beyond continue actions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The fix seems reasonable to me.  See below for a couple of suggestions
regarding the commit message.

On 06/10/2014 02:37 AM, Fabian Ruch wrote:
> [...]
> -- >8 --
> Subject: rebase -i: Remember merge options beyond continue actions
> 
> If the user explicitly specified a merge strategy or strategy options,
> "rebase --interactive" started using the default merge strategy again
> after "rebase --continue".
> 
> This problem gets fixed by this commit. Add test.

Please phrase commit messages in the imperative voice, as if commanding
git to fix itself.  Maybe

    If the user explicitly specified a merge strategy or strategy
    options, continue to use that strategy/option after
    "rebase --continue".  Add a test of the corrected behavior.

> Since the "rebase" options "-s" and "-X" imply "--merge", we can simply
> remove the "do_merge" guard in the interactive mode and always compile
> the "cherry-pick" arguments from the "rebase" state variables "strategy"
> and "strategy_opts".
> 
> Reported-by: Diogo de Campos <campos@xxxxxxxxxxx>
> Signed-off-by: Fabian Ruch <bafain@xxxxxxxxx>

I expect it took you a while to figure out how the strategy-related
options are handled and propagated from one step of an interactive
rebase to the next and why your fix is correct.  It certainly took *me*
a while even though I had your patch in front of me :-)

It is helpful if you give reviewers and future readers the benefit of
your hard work by spoon-feeding them more of the backstory.  I suggest
expanding your justification to something like this (correct me if I've
misunderstood something!):

    If --merge is specified or implied by -s or -X, then "strategy" and
    "strategy_opts" are set to values from which "strategy_args" can be
    derived; otherwise they are set to empty strings.  Either way,
    their values are propagated from one step of an interactive rebase
    to the next via state files.

    "do_merge", on the other hand, is *not* propagated to later steps of
    an interactive rebase.  Therefore, making the initialization of
    "strategy_args" conditional on "do_merge" being set prevents later
    steps of an interactive rebase from setting it correctly.

    Luckily, we don't need the "do_merge" guard at all.  If the rebase
    was started without --merge, then "strategy" and "strategy_opts"
    are both the empty string, which results in "strategy_args" also
    being set to the empty string, which is just what we want in that
    situation.  So remove the "do_merge" guard and derive
    "strategy_args" from "strategy" and "strategy_opts" every time.

Michael

> ---
>  git-rebase--interactive.sh    | 18 +++++++-----------
>  t/t3404-rebase-interactive.sh | 16 ++++++++++++++++
>  2 files changed, 23 insertions(+), 11 deletions(-)
> 
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index 6ec9d3c..817c933 100644
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -77,17 +77,13 @@ amend="$state_dir"/amend
>  rewritten_list="$state_dir"/rewritten-list
>  rewritten_pending="$state_dir"/rewritten-pending
>  
> -strategy_args=
> -if test -n "$do_merge"
> -then
> -	strategy_args=${strategy:+--strategy=$strategy}
> -	eval '
> -		for strategy_opt in '"$strategy_opts"'
> -		do
> -			strategy_args="$strategy_args -X$(git rev-parse --sq-quote "${strategy_opt#--}")"
> -		done
> -	'
> -fi
> +strategy_args=${strategy:+--strategy=$strategy}
> +eval '
> +	for strategy_opt in '"$strategy_opts"'
> +	do
> +		strategy_args="$strategy_args -X$(git rev-parse --sq-quote "${strategy_opt#--}")"
> +	done
> +'
>  
>  GIT_CHERRY_PICK_HELP="$resolvemsg"
>  export GIT_CHERRY_PICK_HELP
> diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
> index c0023a5..73849f1 100755
> --- a/t/t3404-rebase-interactive.sh
> +++ b/t/t3404-rebase-interactive.sh
> @@ -998,6 +998,22 @@ test_expect_success 'rebase -i with --strategy and -X' '
>  	test $(cat file1) = Z
>  '
>  
> +test_expect_success 'interrupted rebase -i with --strategy and -X' '
> +	git checkout -b conflict-merge-use-theirs-interrupted conflict-branch &&
> +	git reset --hard HEAD^ &&
> +	>breakpoint &&
> +	git add breakpoint &&
> +	git commit -m "breakpoint for interactive mode" &&
> +	echo five >conflict &&
> +	echo Z >file1 &&
> +	git commit -a -m "one file conflict" &&
> +	set_fake_editor &&
> +	FAKE_LINES="edit 1 2" git rebase -i --strategy=recursive -Xours conflict-branch &&
> +	git rebase --continue &&
> +	test $(git show conflict-branch:conflict) = $(cat conflict) &&
> +	test $(cat file1) = Z
> +'
> +
>  test_expect_success 'rebase -i error on commits with \ in message' '
>  	current_head=$(git rev-parse HEAD)
>  	test_when_finished "git rebase --abort; git reset --hard $current_head; rm -f error" &&
> 


-- 
Michael Haggerty
mhagger@xxxxxxxxxxxx
http://softwareswirl.blogspot.com/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]