Re: [PATCH 10/11] rebase --apply: set ORIG_HEAD correctly

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

 



"Phillip Wood via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

> From: Phillip Wood <phillip.wood@xxxxxxxxxxxxx>
>
> At the start of a rebase ORIG_HEAD is updated to tip of the branch
> being rebased. Unfortunately reset_head() always uses the current
> value of HEAD for this which is incorrect if the rebase is started
> with 'git rebase <upstream> <branch>' as in that case ORIG_HEAD should
> be updated to <branch>. This only affects the "apply" backend as the
> "merge" backend does not yet use reset_head() for the initial
> checkout. Fix this by passing in orig_head when calling reset_head()
> and add some regression tests.

All correct.  It is somewhat surprising that this wasn't caught and
reported as an issue for this long X-<.

> +	const struct object_id *orig_head;
>  	 /* Optional branch to switch to */
>  	const char *branch;
>  	/* Flags defined above */
> diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh
> index 738fbae9b29..be63456c5b9 100755
> --- a/t/t3418-rebase-continue.sh
> +++ b/t/t3418-rebase-continue.sh
> @@ -323,4 +323,30 @@ test_expect_success 'there is no --no-reschedule-failed-exec in an ongoing rebas
>  	test_expect_code 129 git rebase --edit-todo --no-reschedule-failed-exec
>  '
>  
> +test_orig_head_helper() {

Need SP before "()" in addition to after it.  Ditto for the other one.

> +	test_when_finished 'git rebase --abort &&
> +		git checkout topic &&
> +		git reset --hard commit-new-file-F2-on-topic-branch' &&
> +	git update-ref -d ORIG_HEAD &&
> +	test_must_fail git rebase "$@" &&
> +	test_cmp_rev ORIG_HEAD commit-new-file-F2-on-topic-branch
> +}
> +
> +test_orig_head() {
> +	type=$1
> +	test_expect_success "rebase $type sets ORIG_HEAD correctly" '
> +		git checkout topic &&
> +		git reset --hard commit-new-file-F2-on-topic-branch &&
> +		test_orig_head_helper $type main
> +	'
> +
> +	test_expect_success "rebase $type <upstream> <branch> sets ORIG_HEAD correctly" '
> +		git checkout main &&
> +		test_orig_head_helper $type main topic
> +	'
> +}
> +
> +test_orig_head --apply
> +test_orig_head --merge
> +
>  test_done



[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]

  Powered by Linux