[PATCH v3 0/2] rebase: update HEAD when is an oid

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

 



Fixes a bug [1] reported by Michael McClimon where rebase with oids will
erroneously update the branch HEAD points to.

 1. https://lore.kernel.org/git/xmqqsfrpbepd.fsf@gitster.g/

This patch has two parts:

 * updates rebase setup test to add some tags we will use, while swapping
   out manual commit creation with the test_commit helper
 * sets RESET_HARD_DETACH flag if branch is not a valid refname

changes since v2:

 * remove BUG assertion

changes since v1:

 * only set RESET_HEAD_DETACH if is not a valid branch
 * updated tests to use existing setup

John Cai (2):
  rebase: use test_commit helper in setup
  rebase: set REF_HEAD_DETACH in checkout_up_to_date()

 builtin/rebase.c  |  5 ++++-
 t/t3400-rebase.sh | 18 +++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)


base-commit: b896f729e240d250cf56899e6a0073f6aa469f5d
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1226%2Fjohn-cai%2Fjc%2Ffix-rebase-oids-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1226/john-cai/jc/fix-rebase-oids-v3
Pull-Request: https://github.com/git/git/pull/1226

Range-diff vs v2:

 1:  f3f084adfa6 ! 1:  f658eb00bcd rebase: use test_commit helper in setup
     @@ Commit message
          can use. This uses the test_commit helper so we can replace some lines
          that add a commit manually.
      
     +    Setting logAllRefUpdates is not necessary because it's on by default for
     +    repositories with a working tree.
     +
          Helped-by: Phillip Wood <phillip.wood123@xxxxxxxxx>
          Signed-off-by: John Cai <johncai86@xxxxxxxxx>
      
 2:  0e3c73375c1 ! 2:  bd1c9537ffc rebase: set REF_HEAD_DETACH in checkout_up_to_date()
     @@ builtin/rebase.c: static int checkout_up_to_date(struct rebase_options *options)
       	if (reset_head(the_repository, &ropts) < 0)
       		ret = error(_("could not switch to %s"), options->switch_to);
      
     - ## reset.c ##
     -@@ reset.c: int reset_head(struct repository *r, const struct reset_head_opts *opts)
     - 	if (opts->branch_msg && !opts->branch)
     - 		BUG("branch reflog message given without a branch");
     - 
     -+	if (switch_to_branch && opts->flags & RESET_HEAD_DETACH)
     -+		BUG("attempting to detach HEAD when branch is given");
     -+
     - 	if (!refs_only && repo_hold_locked_index(r, &lock, LOCK_REPORT_ON_ERROR) < 0) {
     - 		ret = -1;
     - 		goto leave_reset_head;
     -
       ## t/t3400-rebase.sh ##
      @@ t/t3400-rebase.sh: test_expect_success 'switch to branch not checked out' '
       	git rebase main other

-- 
gitgitgadget



[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