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

[PATCH v2 04/11] t/lib-rebase: change the implementation of commands with options

From
Charvi Mendiratta <charvi077@gmail.com>
Date
Feb 8, 2021, 19:25 UTC
Message-ID
<20210208192528.21399-5-charvi077@gmail.com>
In-Reply-To
<20210207181439.1178-1-charvi077@gmail.com>

"fixup" and "merge" mirrors the implementation of FAKE_LINES handling of "exec", but the cases are quite different. The argument to "exec" is arbitrary and can have any number of spaces embedded in it, which conflicts with the meaning of spaces in FAKE_LINES, which separate the individual commands in FAKE_LINES. Consequently, "_" was chosen as a placeholder in "exec" to mean "space".

However, "fixup" is very different from "exec". Its arguments are not arbitrary at all, so there isn't a good reason to mirror the choice of "_" to represent a space, which leads to rather unsightly tokens such as "fixup_-C". Let's replace it with simpler tokens such as "fixup-C" and "fixup-c".

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Charvi Mendiratta <charvi077@gmail.com>
---
 t/lib-rebase.sh                 |  8 ++++----
 t/t3437-rebase-fixup-options.sh | 18 +++++++++---------
 2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index e10e38060b..e6bd295c05 100644
--- a/t/lib-rebase.sh
+++ b/t/lib-rebase.sh
@@ -15,8 +15,8 @@
 #       specified line.
 #
 #   "<cmd> <lineno>" -- add a line with the specified command
-#       ("pick", "squash", "fixup", "edit", "reword" or "drop") and the
-#       SHA1 taken from the specified line.
+#      ("pick", "squash", "fixup"|"fixup-C"|"fixup-c", "edit", "reword" or "drop")
+#      and the SHA1 taken from the specified line.
 #
 #   "exec_cmd_with_args" -- add an "exec cmd with args" line.
 #
@@ -53,8 +53,8 @@ set_fake_editor () {
 			action="$line";;
 		exec_*|x_*|break|b)
 			echo "$line" | sed 's/_/ /g' >> "$1";;
-		merge_*|fixup_*)
-			action=$(echo "$line" | sed 's/_/ /g');;
+		merge-*|fixup-*)
+			action=$(echo "$line" | sed 's/-/ -/');;
 		"#")
 			echo '# comment' >> "$1";;
 		">")
diff --git a/t/t3437-rebase-fixup-options.sh b/t/t3437-rebase-fixup-options.sh
index 945df2555b..36dee15c4b 100755
--- a/t/t3437-rebase-fixup-options.sh
+++ b/t/t3437-rebase-fixup-options.sh
@@ -112,7 +112,7 @@ test_expect_success 'setup' '
 test_expect_success 'simple fixup -C works' '
 	test_when_finished "test_might_fail git rebase --abort" &&
 	git checkout --detach A2 &&
-	FAKE_LINES="1 fixup_-C 2" git rebase -i B &&
+	FAKE_LINES="1 fixup-C 2" git rebase -i B &&
 	test_cmp_rev HEAD^ B &&
 	test_cmp_rev HEAD^{tree} A2^{tree} &&
 	test_commit_message HEAD -m "A2"
@@ -123,7 +123,7 @@ test_expect_success 'simple fixup -c works' '
 	git checkout --detach A2 &&
 	git log -1 --pretty=format:%B >expected-fixup-message &&
 	test_write_lines "" "Modified A2" >>expected-fixup-message &&
-	FAKE_LINES="1 fixup_-c 2" \
+	FAKE_LINES="1 fixup-c 2" \
 		FAKE_COMMIT_AMEND="Modified A2" \
 		git rebase -i B &&
 	test_cmp_rev HEAD^ B &&
@@ -134,7 +134,7 @@ test_expect_success 'simple fixup -c works' '
 test_expect_success 'fixup -C removes amend! from message' '
 	test_when_finished "test_might_fail git rebase --abort" &&
 	git checkout --detach A1 &&
-	FAKE_LINES="1 fixup_-C 2" git rebase -i A &&
+	FAKE_LINES="1 fixup-C 2" git rebase -i A &&
 	test_cmp_rev HEAD^ A &&
 	test_cmp_rev HEAD^{tree} A1^{tree} &&
 	test_commit_message HEAD expected-message &&
@@ -145,7 +145,7 @@ test_expect_success 'fixup -C removes amend! from message' '
 test_expect_success 'fixup -C with conflicts gives correct message' '
 	test_when_finished "test_might_fail git rebase --abort" &&
 	git checkout --detach A1 &&
-	test_must_fail env FAKE_LINES="1 fixup_-C 2" git rebase -i conflicts &&
+	test_must_fail env FAKE_LINES="1 fixup-C 2" git rebase -i conflicts &&
 	git checkout --theirs -- A &&
 	git add A &&
 	FAKE_COMMIT_AMEND=edited git rebase --continue &&
@@ -160,7 +160,7 @@ test_expect_success 'fixup -C with conflicts gives correct message' '
 test_expect_success 'skipping fixup -C after fixup gives correct message' '
 	test_when_finished "test_might_fail git rebase --abort" &&
 	git checkout --detach A3 &&
-	test_must_fail env FAKE_LINES="1 fixup 2 fixup_-C 4" git rebase -i A &&
+	test_must_fail env FAKE_LINES="1 fixup 2 fixup-C 4" git rebase -i A &&
 	git reset --hard &&
 	FAKE_COMMIT_AMEND=edited git rebase --continue &&
 	test_commit_message HEAD -m "B"
@@ -168,7 +168,7 @@ test_expect_success 'skipping fixup -C after fixup gives correct message' '
 
 test_expect_success 'sequence of fixup, fixup -C & squash --signoff works' '
 	git checkout --detach branch &&
-	FAKE_LINES="1 fixup 2 fixup_-C 3 fixup_-C 4 squash 5 fixup_-C 6" \
+	FAKE_LINES="1 fixup 2 fixup-C 3 fixup-C 4 squash 5 fixup-C 6" \
 		FAKE_COMMIT_AMEND=squashed \
 		FAKE_MESSAGE_COPY=actual-squash-message \
 		git -c commit.status=false rebase -ik --signoff A &&
@@ -182,7 +182,7 @@ test_expect_success 'first fixup -C commented out in sequence fixup fixup -C fix
 	test_when_finished "test_might_fail git rebase --abort" &&
 	git checkout branch && git checkout --detach branch~2 &&
 	git log -1 --pretty=format:%b >expected-message &&
-	FAKE_LINES="1 fixup 2 fixup_-C 3 fixup_-C 4" git rebase -i A &&
+	FAKE_LINES="1 fixup 2 fixup-C 3 fixup-C 4" git rebase -i A &&
 	test_cmp_rev HEAD^ A &&
 	test_commit_message HEAD expected-message
 '
@@ -192,7 +192,7 @@ test_expect_success 'multiple fixup -c opens editor once' '
 	git checkout --detach A3 &&
 	base=$(git rev-parse HEAD~4) &&
 	FAKE_COMMIT_MESSAGE="Modified-A3" \
-		FAKE_LINES="1 fixup_-C 2 fixup_-c 3 fixup_-c 4" \
+		FAKE_LINES="1 fixup-C 2 fixup-c 3 fixup-c 4" \
 		EXPECT_HEADER_COUNT=4 \
 		git rebase -i $base &&
 	test_cmp_rev $base HEAD^ &&
@@ -202,7 +202,7 @@ test_expect_success 'multiple fixup -c opens editor once' '
 test_expect_success 'sequence squash, fixup & fixup -c gives combined message' '
 	test_when_finished "test_might_fail git rebase --abort" &&
 	git checkout --detach A3 &&
-	FAKE_LINES="1 squash 2 fixup 3 fixup_-c 4" \
+	FAKE_LINES="1 squash 2 fixup 3 fixup-c 4" \
 		FAKE_MESSAGE_COPY=actual-combined-message \
 		git -c commit.status=false rebase -i A &&
 	test_i18ncmp "$TEST_DIRECTORY/t3437/expected-combined-message" \
-- 
2.29.0.rc1
Previous: Charvi MendirattaNext: Junio C Hamano
Message 30 of 58 in “[Outreachy] Improve the 'fixup [-C | -c]' in interactive rebase”
  1. 0/7 [Outreachy] Improve the 'fixup [-C | -c]' in interactive rebaseCharvi Mendiratta, Feb 7, 2021
  2. 1/7 sequencer: fixup the datatype of the 'flag' argumentCharvi Mendiratta, Feb 7, 2021
  3. 2/7 sequencer: rename a few functionsCharvi Mendiratta, Feb 7, 2021
  4. 3/7 rebase -i: clarify and fix 'fixup -c' rebase-todo helpCharvi Mendiratta, Feb 7, 2021
  5. Eric SunshineFeb 7, 2021
  6. Charvi MendirattaFeb 8, 2021
  7. 7/7 doc/rebase -i: fix typo in the documentation of 'fixup' commandCharvi Mendiratta, Feb 7, 2021
  8. 5/7 t3437: fix indendation of the here-docCharvi Mendiratta, Feb 7, 2021
  9. Eric SunshineFeb 7, 2021
  10. Charvi MendirattaFeb 8, 2021
  11. Phillip WoodFeb 8, 2021
  12. 4/7 t/lib-rebase: change the implementation of commands with optionsCharvi Mendiratta, Feb 7, 2021
  13. 6/7 t/t3437: update the testsCharvi Mendiratta, Feb 7, 2021
  14. Eric SunshineFeb 7, 2021
  15. Charvi MendirattaFeb 8, 2021
  16. Eric SunshineFeb 7, 2021
  17. Charvi MendirattaFeb 8, 2021
  18. 00/11 [Outreachy] Improve the 'fixup [-C | -c]' in interactive rebaseCharvi Mendiratta, Feb 8, 2021
  19. Junio C HamanoFeb 8, 2021
  20. Charvi MendirattaFeb 9, 2021
  21. 01/11 sequencer: fixup the datatype of the 'flag' argumentCharvi Mendiratta, Feb 8, 2021
  22. 02/11 sequencer: rename a few functionsCharvi Mendiratta, Feb 8, 2021
  23. 03/11 rebase -i: clarify and fix 'fixup -c' rebase-todo helpCharvi Mendiratta, Feb 8, 2021
  24. Junio C HamanoFeb 8, 2021
  25. Charvi MendirattaFeb 9, 2021
  26. Eric SunshineFeb 9, 2021
  27. Junio C HamanoFeb 9, 2021
  28. Eric SunshineFeb 9, 2021
  29. Charvi MendirattaFeb 10, 2021
  30. 04/11 t/lib-rebase: change the implementation of commands with optionsCharvi Mendiratta, Feb 8, 2021
  31. Junio C HamanoFeb 8, 2021
  32. Christian CouderFeb 8, 2021
  33. Charvi MendirattaFeb 9, 2021
  34. 05/11 t/t3437: fix indentation of the here-docCharvi Mendiratta, Feb 8, 2021
  35. 06/11 t/t3437: remove the dependency of 'expected-message' file from testsCharvi Mendiratta, Feb 8, 2021
  36. 07/11 t/t3437: check author date of the fixed up commitCharvi Mendiratta, Feb 8, 2021
  37. 10/11 t/t3437: fixup the test 'multiple fixup -c opens editor once'Charvi Mendiratta, Feb 8, 2021
  38. 08/11 t/t3437: simplify and document the test helpersCharvi Mendiratta, Feb 8, 2021
  39. 09/11 t/t3437: cleanup the 'setup' test and use named commits in the testsCharvi Mendiratta, Feb 8, 2021
  40. Junio C HamanoFeb 8, 2021
  41. Charvi MendirattaFeb 9, 2021
  42. 11/11 doc/rebase -i: fix typo in the documentation of 'fixup' commandCharvi Mendiratta, Feb 8, 2021
  43. 00/11 [Outreachy] Improve the 'fixup [-C | -c]' in interactive rebaseCharvi Mendiratta, Feb 10, 2021
  44. Junio C HamanoFeb 11, 2021
  45. Charvi MendirattaFeb 11, 2021
  46. Junio C HamanoFeb 11, 2021
  47. Charvi MendirattaFeb 12, 2021
  48. 01/11 sequencer: fixup the datatype of the 'flag' argumentCharvi Mendiratta, Feb 10, 2021
  49. 03/11 rebase -i: clarify and fix 'fixup -c' rebase-todo helpCharvi Mendiratta, Feb 10, 2021
  50. 05/11 t/t3437: fixup here-docs in the 'setup' testCharvi Mendiratta, Feb 10, 2021
  51. 04/11 t/lib-rebase: update the documentation of FAKE_LINESCharvi Mendiratta, Feb 10, 2021
  52. 02/11 sequencer: rename a few functionsCharvi Mendiratta, Feb 10, 2021
  53. 06/11 t/t3437: remove the dependency of 'expected-message' file from testsCharvi Mendiratta, Feb 10, 2021
  54. 07/11 t/t3437: check the author date of fixed up commitCharvi Mendiratta, Feb 10, 2021
  55. 08/11 t/t3437: simplify and document the test helpersCharvi Mendiratta, Feb 10, 2021
  56. 09/11 t/t3437: use named commits in the testsCharvi Mendiratta, Feb 10, 2021
  57. 10/11 t/t3437: fixup the test 'multiple fixup -c opens editor once'Charvi Mendiratta, Feb 10, 2021
  58. 11/11 doc/rebase -i: fix typo in the documentation of 'fixup' commandCharvi Mendiratta, Feb 10, 2021

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.