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

Re: [PATCH v4 7/9] t3437: test script for fixup [-C|-c] options in interactive rebase

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Feb 4, 2021, 10:46 UTC
Message-ID
<54d1ef0f-6a50-b2cb-3ac6-c313cf9dd2f3@gmail.com>
In-Reply-To
<CAPig+cQO_uHurPn3N-k-UwBFgvx2x8Bx2Uy+=sQxhmj3E6rt7Q@mail.gmail.com>
Hi Eric
Thanks for taking such a close look at this series.
On 02/02/2021 02:01, Eric Sunshine wrote:
Show 13 quoted lines
> On Fri, Jan 29, 2021 at 1:25 PM Charvi Mendiratta <charvi077@gmail.com> wrote:
> [...] 
>> +       ORIG_AUTHOR_NAME="$GIT_AUTHOR_NAME" &&
>> +       ORIG_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" &&
>> +       GIT_AUTHOR_NAME="Amend Author" &&
>> +       GIT_AUTHOR_EMAIL="amend@example.com" &&
>> +       test_commit "$(cat message)" A A1 A1 &&
>> +       test_commit A2 A &&
>> +       test_commit A3 A &&
>> +       GIT_AUTHOR_NAME="$ORIG_AUTHOR_NAME" &&
>> +       GIT_AUTHOR_EMAIL="$ORIG_AUTHOR_EMAIL" &&
> 
> Are the timestamps of these commits meaningful in this context? 

I think we want to ensure that the timestamp of the commits created with the different author are different from the previous commits. We ought to be checking that the author date of the rebased commit matches the author date of the original commit and not the author date of the fixup commit created with the different author.

Show 21 quoted lines
> If not, another way to do this would be to assign the new author
> name/email values in a subshell so that the values do not need to be
> restored manually. For instance:
> 
>      (
>          GIT_AUTHOR_NAME="Amend Author" &&
>          GIT_AUTHOR_EMAIL="amend@example.com" &&
>          test_commit "$(cat message)" A A1 A1 &&
>          test_commit A2 A &&
>          test_commit A3 A
>      ) &&
> 
> It's a matter of taste whether or not that is preferable, though.
> 
>> +       echo B1 >B &&
>> +       test_tick &&
>> +       git commit --fixup=HEAD -a &&
>> +       test_tick &&
> 
> Same question about whether the commit timestamps have any
> significance in these tests.

Same answer as above - we want different author dates so we can check the original author date is not modified.

I'm not sure that we are actually checking the dates yet though it looks like we only check the author name and email at the moment.

Best Wishes
Phillip
Show 106 quoted lines
> If not, then these test_tick() calls
> mislead the reader into thinking that the timestamps are significant,
> thus it would make sense to drop them.
> 
>> +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 &&
> 
> I see that you mirrored the implementation of FAKE_LINES handling of
> "exec" here for "fixup", 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 a very different beast. 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". It would work just as well to use simpler tokens such
> as "fixup-C" and "fixup-c", in which case t/lib-rebase.sh might parse
> them like this (note that I also dropped `g` from the `sed` action):
> 
>      fixup-*)
>          action=$(echo "$line" | sed 's/-/ -/');;
> 
> In fact, the recognized set of options following "fixup" is so small,
> that you could even get by with simpler tokens "fixupC" and "fixupc":
> 
>      fixupC)
>          action="fixup -C";;
>      fixupc)
>          actions="fixup -c";;
> 
> Though it's subjective whether or not "fixupC" and "fixupc" are nicer
> than "fixup-C" and "fixup-c", respectively.
> 
>> +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 &&
>> +       test_cmp_rev HEAD^ A &&
>> +       test_cmp_rev HEAD^{tree} A1^{tree} &&
>> +       test_commit_message HEAD expected-message &&
>> +       get_author HEAD >actual-author &&
>> +       test_cmp expected-author actual-author
>> +'
> 
> This test seems out of place. I would expect to see it added in the
> patch which adds "amend!" functionality.
> 
> Alternatively, if the intention really is to support "amend!" this
> early in the series in [6/9], then the commit message of [6/9] should
> talk about it.
> 
>> +test_expect_success 'fixup -C with conflicts gives correct message' '
>> +       test_when_finished "test_might_fail git rebase --abort" &&
> 
> Is there a reason this isn't written as:
> 
>      test_when_finished "reset_rebase" &&
> 
> which is more common? Is there something non-obvious which makes
> reset_rebase() inappropriate in these tests?
> 
>> +       git checkout --detach A1 &&
>> +       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 &&
>> +       test_cmp_rev HEAD^ conflicts &&
>> +       test_cmp_rev HEAD^{tree} A1^{tree} &&
>> +       test_write_lines "" edited >>expected-message &&
> 
> It feels clunky and fragile for this test to be changing
> "expected-message" which was created in the "setup" test and used
> unaltered up to this point. If the content of "expected-message" is
> really going to change from test to test (as I see it changes again in
> a later test), then it would be easier to reason about the behavior if
> each test gives "expected-message" the precise content it should have
> in that local context. As it is currently implemented, it's too
> difficult to follow along and remember the value of "expected-message"
> from test to test. It also makes it difficult to extend tests or add
> new tests in between existing tests without negatively impacting other
> tests. If each test sets up "expected-message" to the precise content
> needed by the test, then both those problems go away.
> 
>> +test_expect_success 'multiple fixup -c opens editor once' '
>> +       test_when_finished "test_might_fail git rebase --abort" &&
>> +       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" \
>> +               EXPECT_HEADER_COUNT=4 \
>> +               git rebase -i $base &&
>> +       test_cmp_rev $base HEAD^ &&
>> +       test 1 = $(git show | grep Modified-A3 | wc -l)
>> +'
> 
> These days, we would phrase the last part of the test as:
> 
>      git show > raw &&
>      grep Modified-A3 raw >out &&
>      test_line_count = 1 out
> 
Previous: Charvi MendirattaNext: Eric Sunshine
Message 63 of 110 in “[Outreachy] rebase -i: add options to fixup command”
  1. 0/9 [Outreachy] rebase -i: add options to fixup commandCharvi Mendiratta, Jan 8, 2021
  2. 1/9 rebase -i: only write fixup-message when it's neededCharvi Mendiratta, Jan 8, 2021
  3. Taylor BlauJan 13, 2021
  4. Charvi MendirattaJan 14, 2021
  5. Phillip WoodJan 14, 2021
  6. Charvi MendirattaJan 15, 2021
  7. Junio C HamanoJan 15, 2021
  8. Charvi MendirattaJan 16, 2021
  9. 2/9 sequencer: factor out code to append squash messageCharvi Mendiratta, Jan 8, 2021
  10. 3/9 rebase -i: comment out squash!/fixup! subjects from squash messageCharvi Mendiratta, Jan 8, 2021
  11. Taylor BlauJan 13, 2021
  12. Charvi MendirattaJan 14, 2021
  13. Phillip WoodJan 14, 2021
  14. Charvi MendirattaJan 15, 2021
  15. Christian CouderJan 15, 2021
  16. Charvi MendirattaJan 15, 2021
  17. Charvi MendirattaJan 17, 2021
  18. Phillip WoodJan 18, 2021
  19. Charvi MendirattaJan 19, 2021
  20. 4/9 sequencer: pass todo_item to do_pick_commit()Charvi Mendiratta, Jan 8, 2021
  21. 5/9 sequencer: use const variable for commit message commentsCharvi Mendiratta, Jan 8, 2021
  22. Taylor BlauJan 13, 2021
  23. Junio C HamanoJan 13, 2021
  24. Christian CouderJan 14, 2021
  25. Charvi MendirattaJan 14, 2021
  26. 6/9 rebase -i: add fixup [-C | -c] commandCharvi Mendiratta, Jan 8, 2021
  27. Christian CouderJan 14, 2021
  28. Charvi MendirattaJan 14, 2021
  29. 8/9 rebase -i: teach --autosquash to work with amend!Charvi Mendiratta, Jan 8, 2021
  30. 7/9 t3437: test script for fixup [-C|-c] options in interactive rebaseCharvi Mendiratta, Jan 8, 2021
  31. 9/9 doc/git-rebase: add documentation for fixup [-C|-c] optionsCharvi Mendiratta, Jan 8, 2021
  32. 0/9 [Outreachy] rebase -i: add options to fixup commandCharvi Mendiratta, Jan 19, 2021
  33. 0/9 [Outreachy] rebase -i: add options to fixup commandCharvi Mendiratta, Jan 24, 2021
  34. 1/9 rebase -i: only write fixup-message when it's neededCharvi Mendiratta, Jan 24, 2021
  35. 2/9 sequencer: factor out code to append squash messageCharvi Mendiratta, Jan 24, 2021
  36. 3/9 rebase -i: comment out squash!/fixup! subjects from squash messageCharvi Mendiratta, Jan 24, 2021
  37. 4/9 sequencer: pass todo_item to do_pick_commit()Charvi Mendiratta, Jan 24, 2021
  38. 5/9 sequencer: use const variable for commit message commentsCharvi Mendiratta, Jan 24, 2021
  39. 6/9 rebase -i: add fixup [-C | -c] commandCharvi Mendiratta, Jan 24, 2021
  40. 7/9 t3437: test script for fixup [-C|-c] options in interactive rebaseCharvi Mendiratta, Jan 24, 2021
  41. 8/9 rebase -i: teach --autosquash to work with amend!Charvi Mendiratta, Jan 24, 2021
  42. 9/9 doc/git-rebase: add documentation for fixup [-C|-c] optionsCharvi Mendiratta, Jan 24, 2021
  43. 0/9 [Outreachy] rebase -i: add options to fixup commandCharvi Mendiratta, Jan 29, 2021
  44. 1/9 rebase -i: only write fixup-message when it's neededCharvi Mendiratta, Jan 29, 2021
  45. 2/9 sequencer: factor out code to append squash messageCharvi Mendiratta, Jan 29, 2021
  46. 3/9 rebase -i: comment out squash!/fixup! subjects from squash messageCharvi Mendiratta, Jan 29, 2021
  47. 6/9 rebase -i: add fixup [-C | -c] commandCharvi Mendiratta, Jan 29, 2021
  48. Eric SunshineFeb 2, 2021
  49. Charvi MendirattaFeb 2, 2021
  50. Eric SunshineFeb 3, 2021
  51. Charvi MendirattaFeb 4, 2021
  52. Eric SunshineFeb 4, 2021
  53. 9/9 doc/git-rebase: add documentation for fixup [-C|-c] optionsCharvi Mendiratta, Jan 29, 2021
  54. Eric SunshineFeb 2, 2021
  55. Charvi MendirattaFeb 2, 2021
  56. Marc BranchaudFeb 2, 2021
  57. 7/9 t3437: test script for fixup [-C|-c] options in interactive rebaseCharvi Mendiratta, Jan 29, 2021
  58. Eric SunshineFeb 2, 2021
  59. Christian CouderFeb 2, 2021
  60. Charvi MendirattaFeb 2, 2021
  61. Eric SunshineFeb 3, 2021
  62. Charvi MendirattaFeb 4, 2021
  63. Phillip WoodFeb 4, 2021
  64. Eric SunshineFeb 4, 2021
  65. Charvi MendirattaFeb 4, 2021
  66. 4/9 sequencer: pass todo_item to do_pick_commit()Charvi Mendiratta, Jan 29, 2021
  67. 8/9 rebase -i: teach --autosquash to work with amend!Charvi Mendiratta, Jan 29, 2021
  68. Eric SunshineFeb 2, 2021
  69. Charvi MendirattaFeb 2, 2021
  70. 5/9 sequencer: use const variable for commit message commentsCharvi Mendiratta, Jan 29, 2021
  71. 0/8 [Outreachy] rebase -i: add options to fixup commandCharvi Mendiratta, Feb 4, 2021
  72. 1/8 rebase -i: only write fixup-message when it's neededCharvi Mendiratta, Feb 4, 2021
  73. 3/8 rebase -i: comment out squash!/fixup! subjects from squash messageCharvi Mendiratta, Feb 4, 2021
  74. 7/8 t3437: test script for fixup [-C|-c] options in interactive rebaseCharvi Mendiratta, Feb 4, 2021
  75. 6/8 rebase -i: add fixup [-C | -c] commandCharvi Mendiratta, Feb 4, 2021
  76. 2/8 sequencer: factor out code to append squash messageCharvi Mendiratta, Feb 4, 2021
  77. 5/8 sequencer: use const variable for commit message commentsCharvi Mendiratta, Feb 4, 2021
  78. 8/8 doc/git-rebase: add documentation for fixup [-C|-c] optionsCharvi Mendiratta, Feb 4, 2021
  79. 4/8 sequencer: pass todo_item to do_pick_commit()Charvi Mendiratta, Feb 4, 2021
  80. Eric SunshineFeb 5, 2021
  81. Charvi MendirattaFeb 5, 2021
  82. Christian CouderFeb 5, 2021
  83. Eric SunshineFeb 5, 2021
  84. Charvi MendirattaFeb 6, 2021
  85. Junio C HamanoFeb 5, 2021
  86. Charvi MendirattaFeb 6, 2021
  87. 1/9 rebase -i: only write fixup-message when it's neededCharvi Mendiratta, Jan 19, 2021
  88. 2/9 sequencer: factor out code to append squash messageCharvi Mendiratta, Jan 19, 2021
  89. 5/9 sequencer: use const variable for commit message commentsCharvi Mendiratta, Jan 19, 2021
  90. 3/9 rebase -i: comment out squash!/fixup! subjects from squash messageCharvi Mendiratta, Jan 19, 2021
  91. Junio C HamanoJan 21, 2021
  92. Charvi MendirattaJan 21, 2021
  93. Christian CouderJan 21, 2021
  94. Phillip WoodJan 21, 2021
  95. Junio C HamanoJan 21, 2021
  96. Charvi MendirattaJan 22, 2021
  97. Charvi MendirattaJan 22, 2021
  98. 4/9 sequencer: pass todo_item to do_pick_commit()Charvi Mendiratta, Jan 19, 2021
  99. 7/9 t3437: test script for fixup [-C|-c] options in interactive rebaseCharvi Mendiratta, Jan 19, 2021
  100. 8/9 rebase -i: teach --autosquash to work with amend!Charvi Mendiratta, Jan 19, 2021
  101. 9/9 doc/git-rebase: add documentation for fixup [-C|-c] optionsCharvi Mendiratta, Jan 19, 2021
  102. Marc BranchaudJan 19, 2021
  103. Charvi MendirattaJan 19, 2021
  104. Marc BranchaudJan 19, 2021
  105. Charvi MendirattaJan 20, 2021
  106. Phillip WoodJan 20, 2021
  107. Charvi MendirattaJan 20, 2021
  108. Phillip WoodJan 20, 2021
  109. Charvi MendirattaJan 20, 2021
  110. 6/9 rebase -i: add fixup [-C | -c] commandCharvi Mendiratta, Jan 19, 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.