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

Re: [PATCH 1/3] t3403: fix commit authorship

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 15, 2021, 17:36 UTC
Message-ID
<xmqqsfzasj80.fsf@gitster.g>
In-Reply-To
<nycvar.QRO.7.76.6.2108142350420.59@tvgsbejvaqbjf.bet>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 12 quoted lines
>> > Good point.  The commit tagged with amended-goodbye is later used in
>> > some tests that ensure the author ident does not change across a
>> > rebase.  If this commit gets created without authorship customized
>> > (i.e. before Phillip's fix), we would not catch a possible breakage
>> > to make rebase discard the original authorship information.
>> >
>> > But with this fix, we now can catch such a breakage.
>>
>> I'll expand the commit message to make that clear
>
> Maybe you could even add a `test another.author@example.com = $(git show
> -s --format=%ae HEAD)`?

The version I have from Phillip has updated log message already, but not with such a regression prevention.

The test that the patch under discussion corrects does this:
    test_expect_success 'correct authorship when committing empty pick' '
        test_when_finished "git rebase --abort" &&
        test_must_fail git rebase -i --onto goodbye \
                amended-goodbye^ amended-goodbye &&
        git commit --allow-empty &&
        git log --pretty=format:"%an <%ae>%n%ad%B" -1 amended-goodbye >expect &&
        git log --pretty=format:"%an <%ae>%n%ad%B" -1 HEAD >actual &&
        test_cmp expect actual
    '

to ensure that the authorship is the same between the original (i.e. amended-goodbye) and the rebased (i.e. HEAD), with the expectation that a bug may lose the authorship and instead use the default one used in the test suite. What this test truly cares is not that amended-goodbye was authored by another.author, but it was not written by the default author.

We could test both, like the attached patch, for completeness. The first half makes sure amended-goodbye (the original) was written by the another.author, and the other one makes sure that author is not the one we use to prepare commits for the tests by default.

I do not think the latter is actually a good idea ("As long as the command produces a result different from THIS, any random garbage is accepted" does not make a good test), so perhaps the first half would be good enough.

 t/t3403-rebase-skip.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git c/t/t3403-rebase-skip.sh w/t/t3403-rebase-skip.sh
index e26762d0b2..1405720767 100755
--- c/t/t3403-rebase-skip.sh
+++ w/t/t3403-rebase-skip.sh
@@ -40,6 +40,14 @@ test_expect_success setup '
 	test_tick &&
 	git tag amended-goodbye &&
 
+	# Make sure the authorship info is different from the default one
+	echo "Another Author <another.author@example.com>" >expect &&
+	git log --pretty=format:"%an <%ae>" -1 amended-goodbye >actual &&
+	test_cmp expect actual &&
+
+	git log --pretty=format:"%an <%ae>" -1 goodbye >unexpect &&
+	! test_cmp unexpect actual &&
+
 	git checkout -f skip-reference &&
 	echo moo > hello &&
 	git commit -a -m "we should skip this" &&
Previous: Johannes SchindelinNext: Phillip Wood
Message 7 of 25 in “rebase --continue: remove .git/MERGE_MSG”
  1. 0/3 rebase --continue: remove .git/MERGE_MSGPhillip Wood via GitGitGadget, Aug 10, 2021
  2. 1/3 t3403: fix commit authorshipPhillip Wood via GitGitGadget, Aug 10, 2021
  3. Elijah NewrenAug 10, 2021
  4. Junio C HamanoAug 10, 2021
  5. Phillip WoodAug 12, 2021
  6. Johannes SchindelinAug 14, 2021
  7. Junio C HamanoAug 15, 2021
  8. Phillip WoodAug 15, 2021
  9. Junio C HamanoAug 16, 2021
  10. Phillip WoodAug 17, 2021
  11. 2/3 rebase --apply: restore some testsPhillip Wood via GitGitGadget, Aug 10, 2021
  12. Elijah NewrenAug 10, 2021
  13. Phillip WoodAug 12, 2021
  14. 3/3 rebase --continue: remove .git/MERGE_MSGPhillip Wood via GitGitGadget, Aug 10, 2021
  15. Elijah NewrenAug 10, 2021
  16. 0/3 rebase --continue: remove .git/MERGE_MSGPhillip Wood via GitGitGadget, Aug 12, 2021
  17. 1/3 t3403: fix commit authorshipPhillip Wood via GitGitGadget, Aug 12, 2021
  18. 2/3 rebase --apply: restore some testsPhillip Wood via GitGitGadget, Aug 12, 2021
  19. 3/3 rebase --continue: remove .git/MERGE_MSGPhillip Wood via GitGitGadget, Aug 12, 2021
  20. Junio C HamanoAug 13, 2021
  21. Phillip WoodAug 14, 2021
  22. Elijah NewrenAug 13, 2021
  23. Junio C HamanoAug 13, 2021
  24. Elijah NewrenAug 13, 2021
  25. Phillip WoodAug 14, 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.