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

[PATCH v9 2/9] t3432: test rebase fast-forward behavior

From
Denton Liu <liu.denton@gmail.com>
Date
Aug 25, 2019, 09:12 UTC
Message-ID
<bc8998079dfce14e88e3c6145740fda04d1c82fe.1566724236.git.liu.denton@gmail.com>
In-Reply-To
<cover.1566724236.git.liu.denton@gmail.com>

When rebase is run on a branch that can be fast-forwarded, this should automatically be done. Create test to ensure this behavior happens.

There are some cases that currently don't pass. The first case is where a feature and master have diverged, running "git rebase master... master" causes a full rebase to happen even though a fast-forward should happen.

The second case is when we are doing "git rebase --fork-point" and a fork-point commit is found. Once again, a full rebase happens even though a fast-forward should happen.

Mark these cases as failure so we can fix it later.
Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 t/t3432-rebase-fast-forward.sh | 72 ++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100755 t/t3432-rebase-fast-forward.sh
diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh
new file mode 100755
index 0000000000..f49af274e0
--- /dev/null
+++ b/t/t3432-rebase-fast-forward.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# Copyright (c) 2019 Denton Liu
+#
+
+test_description='ensure rebase fast-forwards commits when possible'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+	test_commit A &&
+	test_commit B &&
+	test_commit C &&
+	test_commit D &&
+	git checkout -t -b side
+'
+
+test_rebase_same_head () {
+	status="$1" &&
+	shift &&
+	test_expect_$status "git rebase $* with $changes is no-op" "
+		oldhead=\$(git rev-parse HEAD) &&
+		test_when_finished 'git reset --hard \$oldhead' &&
+		git rebase $* &&
+		newhead=\$(git rev-parse HEAD) &&
+		test_cmp_rev \$oldhead \$newhead
+	"
+}
+
+changes='no changes'
+test_rebase_same_head success
+test_rebase_same_head success master
+test_rebase_same_head success --onto B B
+test_rebase_same_head success --onto B... B
+test_rebase_same_head success --onto master... master
+test_rebase_same_head success --no-fork-point
+test_rebase_same_head success --fork-point master
+test_rebase_same_head failure --fork-point --onto B B
+test_rebase_same_head failure --fork-point --onto B... B
+test_rebase_same_head success --fork-point --onto master... master
+
+test_expect_success 'add work to side' '
+	test_commit E
+'
+
+changes='our changes'
+test_rebase_same_head success
+test_rebase_same_head success master
+test_rebase_same_head success --onto B B
+test_rebase_same_head success --onto B... B
+test_rebase_same_head success --onto master... master
+test_rebase_same_head success --no-fork-point
+test_rebase_same_head success --fork-point master
+test_rebase_same_head failure --fork-point --onto B B
+test_rebase_same_head failure --fork-point --onto B... B
+test_rebase_same_head success --fork-point --onto master... master
+
+test_expect_success 'add work to upstream' '
+	git checkout master &&
+	test_commit F &&
+	git checkout side
+'
+
+changes='our and their changes'
+test_rebase_same_head success --onto B B
+test_rebase_same_head success --onto B... B
+test_rebase_same_head failure --onto master... master
+test_rebase_same_head failure --fork-point --onto B B
+test_rebase_same_head failure --fork-point --onto B... B
+test_rebase_same_head failure --fork-point --onto master... master
+
+test_done
-- 
2.23.0.248.g3a9dd8fb08
Previous: Denton LiuNext: Denton Liu
Message 84 of 123 in “rebase: learn --keep-base”
  1. 0/3 rebase: learn --keep-baseDenton Liu, Mar 23, 2019
  2. 1/3 rebase: teach rebase --keep-baseDenton Liu, Mar 23, 2019
  3. Eric SunshineMar 24, 2019
  4. Junio C HamanoMar 24, 2019
  5. Denton LiuMar 25, 2019
  6. Denton LiuMar 25, 2019
  7. Junio C HamanoApr 1, 2019
  8. Junio C HamanoMar 24, 2019
  9. Denton LiuMar 25, 2019
  10. Johannes SchindelinMar 25, 2019
  11. Denton LiuMar 25, 2019
  12. Johannes SchindelinMar 26, 2019
  13. 2/3 t3416: test rebase --keep-baseDenton Liu, Mar 23, 2019
  14. 3/3 git-rebase.txt: document --keep-base optionDenton Liu, Mar 23, 2019
  15. Junio C HamanoMar 24, 2019
  16. Denton LiuMar 25, 2019
  17. Junio C HamanoApr 1, 2019
  18. Ævar Arnfjörð BjarmasonMar 26, 2019
  19. Denton LiuMar 26, 2019
  20. Ævar Arnfjörð BjarmasonMar 26, 2019
  21. Denton LiuMar 26, 2019
  22. Ævar Arnfjörð BjarmasonMar 27, 2019
  23. rebase: teach rebase --keep-baseDenton Liu, Mar 28, 2019
  24. Ævar Arnfjörð BjarmasonMar 28, 2019
  25. Johannes SchindelinMar 29, 2019
  26. Denton LiuMar 29, 2019
  27. Junio C HamanoApr 1, 2019
  28. 0/4 rebase: teach rebase --keep-baseDenton Liu, Apr 1, 2019
  29. 1/4 t3431: add rebase --fork-point testsDenton Liu, Apr 1, 2019
  30. Denton LiuApr 4, 2019
  31. SZEDER GáborApr 5, 2019
  32. Junio C HamanoApr 8, 2019
  33. Johannes SchindelinApr 5, 2019
  34. Denton LiuApr 5, 2019
  35. Johannes SixtApr 5, 2019
  36. Johannes SchindelinApr 5, 2019
  37. Johannes SchindelinApr 5, 2019
  38. SZEDER GáborApr 5, 2019
  39. 2/4 t3432: test rebase fast-forward behaviorDenton Liu, Apr 1, 2019
  40. 3/4 rebase: fast-forward --onto in more casesDenton Liu, Apr 1, 2019
  41. Junio C HamanoApr 2, 2019
  42. Junio C HamanoApr 2, 2019
  43. Denton LiuApr 2, 2019
  44. 4/4 rebase: teach rebase --keep-baseDenton Liu, Apr 1, 2019
  45. 0/4 rebase: teach rebase --keep-baseDenton Liu, Apr 5, 2019
  46. 1/4 t3431: add rebase --fork-point testsDenton Liu, Apr 5, 2019
  47. 2/4 t3432: test rebase fast-forward behaviorDenton Liu, Apr 5, 2019
  48. 4/4 rebase: teach rebase --keep-baseDenton Liu, Apr 5, 2019
  49. 3/4 rebase: fast-forward --onto in more casesDenton Liu, Apr 5, 2019
  50. 0/5 rebase: teach rebase --keep-baseDenton Liu, Apr 15, 2019
  51. 1/5 t3431: add rebase --fork-point testsDenton Liu, Apr 15, 2019
  52. 2/5 t3432: test rebase fast-forward behaviorDenton Liu, Apr 15, 2019
  53. 3/5 rebase: fast-forward --onto in more casesDenton Liu, Apr 15, 2019
  54. Junio C HamanoApr 16, 2019
  55. Phillip WoodApr 16, 2019
  56. Denton LiuApr 17, 2019
  57. Phillip WoodApr 17, 2019
  58. Denton LiuApr 19, 2019
  59. 4/5 rebase: fast-forward --fork-point in more casesDenton Liu, Apr 15, 2019
  60. 5/5 rebase: teach rebase --keep-baseDenton Liu, Apr 15, 2019
  61. 0/5 rebase: teach rebase --keep-baseDenton Liu, Apr 17, 2019
  62. 1/6 t3431: add rebase --fork-point testsDenton Liu, Apr 17, 2019
  63. 2/6 t3432: test rebase fast-forward behaviorDenton Liu, Apr 17, 2019
  64. 3/6 rebase: refactor can_fast_forward into goto towerDenton Liu, Apr 17, 2019
  65. 4/6 rebase: fast-forward --onto in more casesDenton Liu, Apr 17, 2019
  66. Phillip WoodApr 17, 2019
  67. 5/6 rebase: fast-forward --fork-point in more casesDenton Liu, Apr 17, 2019
  68. 6/6 rebase: teach rebase --keep-baseDenton Liu, Apr 17, 2019
  69. 0/6 rebase: learn --keep-baseDenton Liu, Apr 21, 2019
  70. 1/6 t3431: add rebase --fork-point testsDenton Liu, Apr 21, 2019
  71. Denton LiuApr 23, 2019
  72. 2/6 t3432: test rebase fast-forward behaviorDenton Liu, Apr 21, 2019
  73. 3/6 rebase: refactor can_fast_forward into goto towerDenton Liu, Apr 21, 2019
  74. 4/6 rebase: fast-forward --onto in more casesDenton Liu, Apr 21, 2019
  75. 5/6 rebase: fast-forward --fork-point in more casesDenton Liu, Apr 21, 2019
  76. 6/6 rebase: teach rebase --keep-baseDenton Liu, Apr 21, 2019
  77. 00/13 learn --keep-base & moreÆvar Arnfjörð Bjarmason, May 8, 2019
  78. Junio C HamanoMay 8, 2019
  79. Junio C HamanoJul 19, 2019
  80. Denton LiuJul 19, 2019
  81. 0/9 rebase: learn --keep-base and improvements on fast-forward behaviourDenton Liu, Aug 25, 2019
  82. 1/9 t3431: add rebase --fork-point testsDenton Liu, Aug 25, 2019
  83. 3/9 t3432: distinguish "noop-same" v.s. "work-same" in "same head" testsDenton Liu, Aug 25, 2019
  84. 2/9 t3432: test rebase fast-forward behaviorDenton Liu, Aug 25, 2019
  85. 4/9 t3432: test for --no-ff's interaction with fast-forwardDenton Liu, Aug 25, 2019
  86. 5/9 rebase: refactor can_fast_forward into goto towerDenton Liu, Aug 25, 2019
  87. Pratyush YadavAug 25, 2019
  88. Denton LiuAug 26, 2019
  89. 6/9 rebase: fast-forward --onto in more casesDenton Liu, Aug 25, 2019
  90. 7/9 rebase: fast-forward --fork-point in more casesDenton Liu, Aug 25, 2019
  91. 8/9 rebase tests: test linear branch topologyDenton Liu, Aug 25, 2019
  92. 9/9 rebase: teach rebase --keep-baseDenton Liu, Aug 25, 2019
  93. Philip OakleyAug 25, 2019
  94. Junio C HamanoAug 26, 2019
  95. 0/9 rebase: learn --keep-base and improvements on fast-forward behaviourDenton Liu, Aug 27, 2019
  96. 1/9 t3431: add rebase --fork-point testsDenton Liu, Aug 27, 2019
  97. 2/9 t3432: test rebase fast-forward behaviorDenton Liu, Aug 27, 2019
  98. 3/9 t3432: distinguish "noop-same" v.s. "work-same" in "same head" testsDenton Liu, Aug 27, 2019
  99. 4/9 t3432: test for --no-ff's interaction with fast-forwardDenton Liu, Aug 27, 2019
  100. SZEDER GáborAug 27, 2019
  101. 5/9 rebase: refactor can_fast_forward into goto towerDenton Liu, Aug 27, 2019
  102. 6/9 rebase: fast-forward --onto in more casesDenton Liu, Aug 27, 2019
  103. 7/9 rebase: fast-forward --fork-point in more casesDenton Liu, Aug 27, 2019
  104. 8/9 rebase tests: test linear branch topologyDenton Liu, Aug 27, 2019
  105. 9/9 rebase: teach rebase --keep-baseDenton Liu, Aug 27, 2019
  106. 01/13 t3431: add rebase --fork-point testsÆvar Arnfjörð Bjarmason, May 8, 2019
  107. 02/13 t3432: test rebase fast-forward behaviorÆvar Arnfjörð Bjarmason, May 8, 2019
  108. 03/13 t3432: distinguish "noop-same" v.s. "work-same" in "same head" testsÆvar Arnfjörð Bjarmason, May 8, 2019
  109. 04/13 t3432: test for --no-ff's interaction with fast-forwardÆvar Arnfjörð Bjarmason, May 8, 2019
  110. 05/13 rebase: refactor can_fast_forward into goto towerÆvar Arnfjörð Bjarmason, May 8, 2019
  111. 06/13 rebase: fast-forward --onto in more casesÆvar Arnfjörð Bjarmason, May 8, 2019
  112. 07/13 rebase: fast-forward --fork-point in more casesÆvar Arnfjörð Bjarmason, May 8, 2019
  113. 09/13 rebase tests: test linear branch topologyÆvar Arnfjörð Bjarmason, May 8, 2019
  114. 08/13 rebase: teach rebase --keep-baseÆvar Arnfjörð Bjarmason, May 8, 2019
  115. 10/13 rebase: don't rebase linear topology with --fork-pointÆvar Arnfjörð Bjarmason, May 8, 2019
  116. 11/13 rebase: eliminate side-effects from can_fast_forward()Ævar Arnfjörð Bjarmason, May 8, 2019
  117. Johannes SchindelinMay 17, 2019
  118. 12/13 rebase: add a should_fast_forward() utility functionÆvar Arnfjörð Bjarmason, May 8, 2019
  119. 13/13 WIP: can_fast_forward() support for --preserve-merges and --rebase-mergesÆvar Arnfjörð Bjarmason, May 8, 2019
  120. Johannes SchindelinMay 17, 2019
  121. Ævar Arnfjörð BjarmasonApr 6, 2019
  122. Denton LiuApr 6, 2019
  123. Ævar Arnfjörð BjarmasonApr 13, 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.