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

Re: [PATCH] sequencer.c: terminate the last line of author-script properly

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 12, 2018, 20:49 UTC
Message-ID
<xmqqr2k8uqlw.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<xmqqa7qww6uk.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 15 quoted lines
> I _think_ the right and safe way to fix taht is to do something like
> this:
>
> 	test -f .git/rebase-merge/author-script &&
> 	(
> 		safe_unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL ... &&
> 		eval "$(cat .git/rebase-merge/author-script)" &&
> 		test ... &&
> 		test ... &&
> 		test ...
> 	)
>
> That way, we won't have to worry about GIT_AUTHOR_* variables
> getting modified and affecting the tests that come later in the
> script.

It turns out that the use of subshell is *essential* for this test, as GIT_AUTHOR_* variables are exported and must remain so. unsetting and reading back may allows us to ensure that shell variables have the expected value, but then they are no longer exported, which will mean later tests will use whatever random author ident the person or the 'bot who is running the tests, not the one expected to be used by the test author(s).

For tonight's pushout, I'll queue this on top.
-- >8 --
From: Junio C Hamano <gitster@pobox.com>
Date: Thu, 12 Jul 2018 13:23:02 -0700
Subject: [PATCH] SQUASH???
---
 t/t3404-rebase-interactive.sh | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 2d189da2f1..b0cef509ab 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -81,11 +81,13 @@ test_expect_success 'rebase -i writes out .git/rebase-merge/author-script in "ed
 	set_fake_editor &&
 	FAKE_LINES="edit 1" git rebase -i HEAD^ &&
 	test -f .git/rebase-merge/author-script &&
-	unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
-	eval "$(cat .git/rebase-merge/author-script)" &&
-	test "$(git show --quiet --pretty=format:%an)" = "$GIT_AUTHOR_NAME" &&
-	test "$(git show --quiet --pretty=format:%ae)" = "$GIT_AUTHOR_EMAIL" &&
-	test "$(git show --quiet --date=raw --pretty=format:@%ad)" = "$GIT_AUTHOR_DATE"
+	(
+		sane_unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
+		eval "$(cat .git/rebase-merge/author-script)" &&
+		test "$(git show --quiet --pretty=format:%an)" = "$GIT_AUTHOR_NAME" &&
+		test "$(git show --quiet --pretty=format:%ae)" = "$GIT_AUTHOR_EMAIL" &&
+		test "$(git show --quiet --date=raw --pretty=format:@%ad)" = "$GIT_AUTHOR_DATE"
+	)
 '
 
 test_expect_success 'rebase -i with the exec command' '
-- 
2.18.0-129-ge3331758f1
Previous: Johannes SchindelinNext: Phillip Wood
Message 24 of 27 in “sequencer.c: terminate the last line of author-script properly”
  1. sequencer.c: terminate the last line of author-script properlyAkinori MUSHA, Jul 12, 2018
  2. Junio C HamanoJul 12, 2018
  3. Phillip WoodJul 18, 2018
  4. Phillip WoodJul 18, 2018
  5. sequencer: fix quoting in write_author_scriptPhillip Wood, Jul 18, 2018
  6. Junio C HamanoJul 24, 2018
  7. Johannes SchindelinJul 26, 2018
  8. Phillip WoodJul 27, 2018
  9. Johannes SchindelinJul 27, 2018
  10. Phillip WoodJul 30, 2018
  11. Junio C HamanoJul 18, 2018
  12. Junio C HamanoJul 18, 2018
  13. Phillip WoodJul 19, 2018
  14. Johannes SchindelinJul 26, 2018
  15. Junio C HamanoJul 26, 2018
  16. Junio C HamanoJul 12, 2018
  17. Eric SunshineJul 12, 2018
  18. Junio C HamanoJul 12, 2018
  19. Junio C HamanoJul 17, 2018
  20. Akinori MUSHAJul 18, 2018
  21. Johannes SchindelinJul 26, 2018
  22. Junio C HamanoJul 26, 2018
  23. Johannes SchindelinJul 27, 2018
  24. Junio C HamanoJul 12, 2018
  25. Phillip WoodJul 18, 2018
  26. Phillip WoodJul 18, 2018
  27. Phillip WoodJul 18, 2018

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.