From: Phillip Wood <phillip.wood@xxxxxxxxxxxxx> Single quotes should be escaped as \' not \\'. Note that this only affects authors that contain a single quote and then only external scripts that read the author script and users whose git is upgraded from the shell version of rebase -i while rebase was stopped. This is because the parsing in read_env_script() expected the broken version and for some reason sq_dequote() called by read_author_ident() seems to handle the broken quoting correctly. Ideally write_author_script() would be rewritten to use split_ident_line() and sq_quote_buf() but this commit just fixes the immediate bug. Signed-off-by: Phillip Wood <phillip.wood@xxxxxxxxxxxxx> --- This is untested, unfortuantely I don't have really have time to write a test or follow this up at the moment, if someone else want to run with it then please do. sequencer.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sequencer.c b/sequencer.c index 5354d4d51e..0b78d1f100 100644 --- a/sequencer.c +++ b/sequencer.c @@ -638,21 +638,21 @@ static int write_author_script(const char *message) else if (*message != '\'') strbuf_addch(&buf, *(message++)); else - strbuf_addf(&buf, "'\\\\%c'", *(message++)); + strbuf_addf(&buf, "'\\%c'", *(message++)); strbuf_addstr(&buf, "'\nGIT_AUTHOR_EMAIL='"); while (*message && *message != '\n' && *message != '\r') if (skip_prefix(message, "> ", &message)) break; else if (*message != '\'') strbuf_addch(&buf, *(message++)); else - strbuf_addf(&buf, "'\\\\%c'", *(message++)); + strbuf_addf(&buf, "'\\%c'", *(message++)); strbuf_addstr(&buf, "'\nGIT_AUTHOR_DATE='@"); while (*message && *message != '\n' && *message != '\r') if (*message != '\'') strbuf_addch(&buf, *(message++)); else - strbuf_addf(&buf, "'\\\\%c'", *(message++)); + strbuf_addf(&buf, "'\\%c'", *(message++)); res = write_message(buf.buf, buf.len, rebase_path_author_script(), 1); strbuf_release(&buf); return res; @@ -666,13 +666,21 @@ static int read_env_script(struct argv_array *env) { struct strbuf script = STRBUF_INIT; int i, count = 0; - char *p, *p2; + const char *p2; + char *p; if (strbuf_read_file(&script, rebase_path_author_script(), 256) <= 0) return -1; for (p = script.buf; *p; p++) - if (skip_prefix(p, "'\\\\''", (const char **)&p2)) + /* + * write_author_script() used to escape "'" incorrectly as + * "'\\\\''" rather than "'\\''" so we check for the correct + * version the incorrect version in case git was upgraded while + * rebase was stopped. + */ + if (skip_prefix(p, "'\\''", &p2) || + skip_prefix(p, "'\\\\''", &p2)) strbuf_splice(&script, p - script.buf, p2 - p, "'", 1); else if (*p == '\'') strbuf_splice(&script, p-- - script.buf, 1, "", 0); -- 2.18.0