git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 0/3] allow checkout and branch to create branches on a merge base

From
Denton Liu <liu.denton@gmail.com>
Date
Apr 26, 2019, 19:21 UTC
Message-ID
<cover.1556305561.git.liu.denton@gmail.com>
In-Reply-To
<cover.1556226502.git.liu.denton@gmail.com>
Thanks for your comments, Eric and Junio.

Eric, I've combined the `test_when_finished` calls together so that the statements within appear in a more "logical" order.

Junio, I've taken your suggestion and moved the change into `create_branch`. Initially, I didn't want to do this because I didn't want to change the semantics of git-branch but introducing the merge base syntax seems to be a positive change so let's do it.

Thanks,
Denton
---
Changes since v1:
* Moved multiple `test_when_finished` calls that appeared in "reverse
  order" into one call that appears in the logical order
* Made create_branch handle merge base revs instead of putting a hack
  into checkout
Denton Liu (3):
  t2018: cleanup in current test
  t2018: demonstrate checkout -b merge base bug
  branch: make create_branch accept a merge base rev
 Documentation/git-branch.txt |  6 +++-
 branch.c                     |  2 +-
 t/t2018-checkout-branch.sh   | 56 +++++++++++++++++++-----------------
 t/t3200-branch.sh            | 14 ++++++---
 4 files changed, 46 insertions(+), 32 deletions(-)
Range-diff against v1:
1:  c0c7171e3d ! 1:  9d04faf29d t2018: cleanup in current test
    @@ -19,8 +19,9 @@
      '
      
      test_expect_success 'checkout -b to a new branch, set to HEAD' '
    -+	test_when_finished test_might_fail git branch -D branch2 &&
    -+	test_when_finished git checkout branch1 &&
    ++	test_when_finished "
    ++		git checkout branch1 &&
    ++		test_might_fail git branch -D branch2" &&
      	do_checkout branch2
      '
      
    @@ -28,8 +29,9 @@
     -	git checkout branch1 &&
     -	git branch -D branch2 &&
     -
    -+	test_when_finished test_might_fail git branch -D branch2 &&
    -+	test_when_finished git checkout branch1 &&
    ++	test_when_finished "
    ++		git checkout branch1 &&
    ++		test_might_fail git branch -D branch2" &&
      	do_checkout branch2 $HEAD1
      '
      
    @@ -45,8 +47,9 @@
      '
      
      test_expect_success 'checkout -f -b to a new branch with unmergeable changes discards changes' '
    -+	test_when_finished test_might_fail git branch -D branch2 &&
    -+	test_when_finished git checkout branch1 &&
    ++	test_when_finished "
    ++		git checkout branch1 &&
    ++		test_might_fail git branch -D branch2" &&
     +
      	# still dirty and on branch1
      	do_checkout branch2 $HEAD1 "-f -b" &&
    @@ -58,9 +61,10 @@
     -
     -	# clean up from previous test
     -	git branch -D branch2 &&
    -+	test_when_finished test_might_fail git branch -D branch2 &&
    -+	test_when_finished git checkout branch1 &&
    -+	test_when_finished git reset --hard &&
    ++	test_when_finished "
    ++		git reset --hard &&
    ++		git checkout branch1 &&
    ++		test_might_fail git branch -D branch2" &&
      
      	setup_dirty_mergeable &&
      	do_checkout branch2 $HEAD1 &&
2:  ff38bdb564 ! 2:  5e8320cd80 t2018: demonstrate checkout -b merge base bug
    @@ -28,21 +28,21 @@
      '
      
     +test_expect_failure 'checkout -b to a merge base' '
    -+	test_when_finished test_might_fail git branch -D branch2 &&
    -+	test_when_finished git checkout branch1 &&
    ++	test_when_finished "
    ++		git checkout branch1 &&
    ++		test_might_fail git branch -D branch2" &&
     +	git checkout -b branch2 branch1...
     +'
     +
      test_expect_success 'checkout -b to a new branch, set to an explicit ref' '
    - 	test_when_finished test_might_fail git branch -D branch2 &&
    - 	test_when_finished git checkout branch1 &&
    + 	test_when_finished "
    + 		git checkout branch1 &&
     @@
      	do_checkout branch2 "" -B
      '
      
     +test_expect_failure 'checkout -B to a merge base' '
     +	git checkout branch1 &&
    -+	git branch -D branch2 &&
     +
     +	git checkout -B branch2 branch1...
     +'
3:  031780431d < -:  ---------- checkout: allow -b/-B to work on a merge base
-:  ---------- > 3:  c91c7535a7 branch: make create_branch accept a merge base rev
-- 
2.21.0.1033.g0e8cc1100c
Previous: Junio C HamanoNext: Denton Liu
Message 11 of 21 in “checkout: allow -b/-B to work on a merge base”
  1. 0/3 checkout: allow -b/-B to work on a merge baseDenton Liu, Apr 25, 2019
  2. 1/3 t2018: cleanup in current testDenton Liu, Apr 25, 2019
  3. Eric SunshineApr 25, 2019
  4. Denton LiuApr 26, 2019
  5. Junio C HamanoApr 26, 2019
  6. Eric SunshineApr 26, 2019
  7. 2/3 t2018: demonstrate checkout -b merge base bugDenton Liu, Apr 25, 2019
  8. 3/3 checkout: allow -b/-B to work on a merge baseDenton Liu, Apr 25, 2019
  9. Junio C HamanoApr 26, 2019
  10. Junio C HamanoApr 26, 2019
  11. 0/3 allow checkout and branch to create branches on a merge baseDenton Liu, Apr 26, 2019
  12. 1/3 t2018: cleanup in current testDenton Liu, Apr 26, 2019
  13. 2/3 t2018: demonstrate checkout -b merge base bugDenton Liu, Apr 26, 2019
  14. 3/3 branch: make create_branch accept a merge base revDenton Liu, Apr 26, 2019
  15. Junio C HamanoApr 26, 2019
  16. Denton LiuApr 26, 2019
  17. Denton LiuApr 26, 2019
  18. Junio C HamanoApr 27, 2019
  19. 0/2 allow checkout and branch to create branches on a merge baseDenton Liu, Apr 27, 2019
  20. 1/2 t2018: cleanup in current testDenton Liu, Apr 27, 2019
  21. 2/2 branch: make create_branch accept a merge base revDenton Liu, Apr 27, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.