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

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

From
PWPhillip Wood <phillip.wood@talktalk.net>
Date
Jul 18, 2018, 13:58 UTC
Message-ID
<a39862e1-ad27-6989-6a32-1898448525f0@talktalk.net>
In-Reply-To
<aad05e61-db99-429e-bbe6-a8f91ef18e3f@talktalk.net>
On 18/07/18 14:50, Phillip Wood wrote:
Show 69 quoted lines
> 
> Hi Akinori
> On 12/07/18 12:18, Akinori MUSHA wrote:
>>
>> It looks like write_author_script() intends to write out a file in
>> Bourne shell syntax, but it doesn't put a closing single quote on the
>> last line.
>>
>> This patch makes .git/rebase-merge/author-script actually parsable by
>> sh(1) by adding a single quote and a linefeed to terminate the line
>> properly.
>>
>> Signed-off-by: Akinori MUSHA <knu@idaemons.org>
>> ---
>>   sequencer.c                   |  1 +
>>   t/t3404-rebase-interactive.sh | 13 +++++++++++++
>>   2 files changed, 14 insertions(+)
>>
>> diff --git a/sequencer.c b/sequencer.c
>> index 4034c0461..5f32b6df1 100644
>> --- a/sequencer.c
>> +++ b/sequencer.c
>> @@ -651,6 +651,7 @@ static int write_author_script(const char *message)
>>               strbuf_addch(&buf, *(message++));
>>           else
>>               strbuf_addf(&buf, "'\\\\%c'", *(message++));
>> +    strbuf_addstr(&buf, "'\n");
>>       res = write_message(buf.buf, buf.len, 
>> rebase_path_author_script(), 1);
>>       strbuf_release(&buf);
>>       return res;
>> diff --git a/t/t3404-rebase-interactive.sh 
>> b/t/t3404-rebase-interactive.sh
>> index 352a52e59..345b103eb 100755
>> --- a/t/t3404-rebase-interactive.sh
>> +++ b/t/t3404-rebase-interactive.sh
>> @@ -75,6 +75,19 @@ test_expect_success 'rebase --keep-empty' '
>>       test_line_count = 6 actual
>>   '
>> +test_expect_success 'rebase -i writes out 
>> .git/rebase-merge/author-script in "edit" that sh(1) can parse' '
>> +    test_when_finished "git rebase --abort ||:" &&
>> +    git checkout master &&
>> +    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"
>> +'
> 
> Have you checked that this test fails without your fix being applied? I 
> just ran
> 
> sh -c 'eval "$(cat .git/rebase-merge/author-script)"; echo 
> "$GIT_AUTHOR_NAME"'
> 
> while a rebase was stopped for an edit and it worked despite the fact 
> that there is a missing quote at the end of the GIT_AUTHOR_DATE in the 
> author script file.
> 
> Best Wishes
> 
> Phillip

Please ignore that, I messed up, there was a closing "'" as I was using the shell version by a mistake.

Sorry for the noise
Phillip
Show 5 quoted lines
>>   test_expect_success 'rebase -i with the exec command' '
>>       git checkout master &&
>>       (
>>
> 
Previous: Phillip Wood
Message 27 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.