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

Re: [PATCH 10/12] t/lib-rebase: prepare for testing `git rebase --rebase-merges`

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jul 26, 2019, 21:08 UTC
Message-ID
<20190726210820.GF9319@genre.crustytoothpaste.net>
In-Reply-To
<nycvar.QRO.7.76.6.1907261555410.21907@tvgsbejvaqbjf.bet>
On 2019-07-26 at 14:01:03, Johannes Schindelin wrote:
> Actually, the part that uses it is not shown in the patch (one of the
> many, many reasons why I try to discourage patch review and encourage
> code review instead). The relevant section currently looks somewhat like
> this:

I feel like I may have communicated poorly earlier, so let me retry asking this in a different way.

Show 23 quoted lines
> -- snip --
> set_fake_editor () {
> 	write_script fake-editor.sh <<-\EOF
> 	case "$1" in
> 	*/COMMIT_EDITMSG)
> 		test -z "$EXPECT_HEADER_COUNT" ||
> 			test "$EXPECT_HEADER_COUNT" = "$(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1")" ||
> 			test "# # GETTEXT POISON #" = "$(sed -n '1p' < "$1")" ||
> 			exit
> 		test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
> 		test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
> 		exit
> 		;;
> 	esac
> 	test -z "$EXPECT_COUNT" ||
> 		test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) ||
> 		exit
> 	test -z "$FAKE_LINES" && exit
> 	grep -v '^#' < "$1" > "$1".tmp
> 	rm -f "$1"
> 	echo 'rebase -i script before editing:'
> 	cat "$1".tmp
> 	action=pick
I believe you changed this line to "action=\&".
Show 14 quoted lines
> 	for line in $FAKE_LINES; do
> 		case $line in
> 		pick|p|squash|s|fixup|f|edit|e|reword|r|drop|d)
> 			action="$line";;
> 		exec_*|x_*|break|b)
> 			echo "$line" | sed 's/_/ /g' >> "$1";;
> 		"#")
> 			echo '# comment' >> "$1";;
> 		">")
> 			echo >> "$1";;
> 		bad)
> 			action="badcmd";;
> 		fakesha)
> 			echo "$action XXXXXXX False commit" >> "$1"
And my question was about this line.
Show 30 quoted lines
> 			action=pick;;
> 		*)
> 			sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1"
> 			action=pick;;
> 		esac
> 	done
> 	echo 'rebase -i script after editing:'
> 	cat "$1"
> 	EOF
> 
> 	test_set_editor "$(pwd)/fake-editor.sh"
> }
> -- snap --
> 
> Most importantly, `action` is used here:
> 
>                         sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1"
> 
> and I changed it to
> 
> 			sed -n "${line}s/^[a-z][a-z]*/$action/p" < "$1".tmp >> "$1"
> 
> In other words, rather than expecting the lines that are used by the
> fake editor to start with `pick`, after this patch, the tests expect the
> todo lists to start with a command consisting of lower-case ASCII
> letters (which catches `pick`, of course, but also `label`, `reset` and
> `merge`).
> 
> After this patch, the fake editor also does not try to replace whatever
> command it finds by `pick`, but it keeps it as-is instead.

Right, that's how I read it, and that part I agree with. I think my question is this: in what case do we execute the "fakesha" case? Are we guaranteed that when we do, action isn't "&"? "&" seems fine for the right-hand side of a sed s-statement, but not as the beginning of a typical line in a sequencer file.

I ask because if we're testing a failure case, we want it to fail for the right reason (e.g., the commit doesn't exist), and not because we're producing invalid data. If the answer in this case is, "Well, we'll always have something else before it which will set $action properly," then that's fine. This is test code, so it need not be bulletproof, but I did want to ask.

If I'm still misunderstanding something, I apologize.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 12 of 39 in “rebase -r: support merge strategies other than recursive”
  1. 00/12 rebase -r: support merge strategies other than recursiveJohannes Schindelin via GitGitGadget, Jul 25, 2019
  2. 02/12 t3427: simplify the `setup` test case significantlyJohannes Schindelin via GitGitGadget, Jul 25, 2019
  3. 01/12 t3427: add a clarifying commentJohannes Schindelin via GitGitGadget, Jul 25, 2019
  4. 04/12 t3427: condense the unnecessarily repetitive test cases into threeJohannes Schindelin via GitGitGadget, Jul 25, 2019
  5. 05/12 t3427: fix erroneous assumptionJohannes Schindelin via GitGitGadget, Jul 25, 2019
  6. 07/12 t3427: fix another incorrect assumptionJohannes Schindelin via GitGitGadget, Jul 25, 2019
  7. 03/12 t3427: move the `filter-branch` invocation into the `setup` caseJohannes Schindelin via GitGitGadget, Jul 25, 2019
  8. 09/12 rebase -r: support merge strategies other than `recursive`Johannes Schindelin via GitGitGadget, Jul 25, 2019
  9. 10/12 t/lib-rebase: prepare for testing `git rebase --rebase-merges`Johannes Schindelin via GitGitGadget, Jul 25, 2019
  10. brian m. carlsonJul 26, 2019
  11. Johannes SchindelinJul 26, 2019
  12. brian m. carlsonJul 26, 2019
  13. Johannes SchindelinJul 31, 2019
  14. 12/12 rebase -r: do not (re-)generate root commits with `--root` *and* `--onto`Johannes Schindelin via GitGitGadget, Jul 25, 2019
  15. 08/12 t3427: mark two test cases as requiring support for `git rebase -p`Johannes Schindelin via GitGitGadget, Jul 25, 2019
  16. 11/12 t3418: test `rebase -r` with merge strategiesJohannes Schindelin via GitGitGadget, Jul 25, 2019
  17. 06/12 t3427: accommodate for the `rebase --merge` backend having been replacedJohannes Schindelin via GitGitGadget, Jul 25, 2019
  18. Junio C HamanoJul 25, 2019
  19. brian m. carlsonJul 26, 2019
  20. 00/16 rebase -r: support merge strategies other than recursiveJohannes Schindelin via GitGitGadget, Jul 31, 2019
  21. 02/16 t3400: stop referring to the scripted rebaseJohannes Schindelin via GitGitGadget, Jul 31, 2019
  22. 03/16 .gitignore: there is no longer a built-in `git-rebase--interactive`Johannes Schindelin via GitGitGadget, Jul 31, 2019
  23. 06/16 t3427: add a clarifying commentJohannes Schindelin via GitGitGadget, Jul 31, 2019
  24. 04/16 sequencer: the `am` and `rebase--interactive` scripts are goneJohannes Schindelin via GitGitGadget, Jul 31, 2019
  25. 05/16 rebase: fold git-rebase--common into the -p backendJohannes Schindelin via GitGitGadget, Jul 31, 2019
  26. 08/16 t3427: move the `filter-branch` invocation into the `setup` caseJohannes Schindelin via GitGitGadget, Jul 31, 2019
  27. 01/16 Drop unused git-rebase--am.shJohannes Schindelin via GitGitGadget, Jul 31, 2019
  28. 16/16 rebase -r: do not (re-)generate root commits with `--root` *and* `--onto`Johannes Schindelin via GitGitGadget, Jul 31, 2019
  29. 14/16 t/lib-rebase: prepare for testing `git rebase --rebase-merges`Johannes Schindelin via GitGitGadget, Jul 31, 2019
  30. 15/16 t3418: test `rebase -r` with merge strategiesJohannes Schindelin via GitGitGadget, Jul 31, 2019
  31. 13/16 rebase -r: support merge strategies other than `recursive`Johannes Schindelin via GitGitGadget, Jul 31, 2019
  32. 09/16 t3427: condense the unnecessarily repetitive test cases into threeJohannes Schindelin via GitGitGadget, Jul 31, 2019
  33. 12/16 t3427: fix another incorrect assumptionJohannes Schindelin via GitGitGadget, Jul 31, 2019
  34. 10/16 t3427: fix erroneous assumptionJohannes Schindelin via GitGitGadget, Jul 31, 2019
  35. 11/16 t3427: accommodate for the `rebase --merge` backend having been replacedJohannes Schindelin via GitGitGadget, Jul 31, 2019
  36. 07/16 t3427: simplify the `setup` test case significantlyJohannes Schindelin via GitGitGadget, Jul 31, 2019
  37. 17/16 t3427: accelerate this test by using fast-export and fast-importElijah Newren, Sep 4, 2019
  38. Johannes SchindelinSep 9, 2019
  39. Junio C HamanoSep 9, 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.