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

Re: Bug: git-rebase goofs up \n in commit messages

From
Jeff King <peff@peff.net>
Date
May 26, 2007, 00:40 UTC
Message-ID
<20070526004028.GA8940@sigill.intra.peff.net>
In-Reply-To
<465750FE.9000406@iii.hu>
On Fri, May 25, 2007 at 11:11:26PM +0200, Szekeres Istvan wrote:
> while playing with git I found the following bug: if a commit message
> contains "\n" (as a string, not as a character), git-rebase changes this
> string into a literal newline character.
Hmm. The culprit seems to be git-am.sh, line 313:
  SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
and even more exciting, it seems to be a bash vs dash thing. Try this:

$ cat >content-with-escapes <<'EOF' foo \n bar EOF

$ bash bash$ test=$(cat content-with-escapes) bash$ echo $test foo \n bar

$ dash
dash$ test=$(cat content-with-escapes)
dash$ echo $test
foo
 bar
Hmm. It even happens with this:
bash$ export test=$(echo foo \\n bar)
bash$ dash
dash$ echo $test
foo
 bar

I'm not sure what the best workaround is. I am cc'ing Herbert Xu to see if he has any helpful comments.

-Peff
Previous: Szekeres IstvanNext: Herbert Xu
Message 2 of 13 in “Bug: git-rebase goofs up \n in commit messages”
  1. Szekeres IstvanMay 25, 2007
  2. Jeff KingMay 26, 2007
  3. Herbert XuMay 26, 2007
  4. Jeff KingMay 26, 2007
  5. Junio C HamanoMay 26, 2007
  6. Junio C HamanoMay 26, 2007
  7. Jeff KingMay 26, 2007
  8. Junio C HamanoMay 26, 2007
  9. Herbert XuMay 26, 2007
  10. Jeff KingMay 26, 2007
  11. Herbert XuMay 26, 2007
  12. Jeff KingMay 26, 2007
  13. Junio C HamanoMay 26, 2007

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.