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

subtree split prepends "-n<newline>" to commit messages on OS X

From
BHBryan Head <bryan.head@gmail.com>
Date
Jul 26, 2013, 22:47 UTC
Message-ID
<CAFM=nTeRpZ=Y-+4KMCZd8Qj-9K105uSquh8Y=7mC3aqJiE0gbQ@mail.gmail.com>
Looks like this was introduced in 1.8.3.3.
To reproduce, run

git init repo cd repo mkdir splitme touch splitme/foo git add splitme/ git commit -m 'Add foo' git subtree split -P splitme -b splitme-only

After that, I get:
$ git log splitme-only
commit 6ce8124a0b5e52d4bba198144d2f3f664d7b19e7
Author: me
Date:   Fri Jul 26 12:22:27 2013 -0500
    -n
    Add foo
Compared with the original:
$ git log master
commit 6d5164076bd88d1dab8963d91ec013372e58a444
Author: me
Date:   Fri Jul 26 12:22:27 2013 -0500
    Add foo
Notice how `-n<newline>` has been prepended to the commit message.

This was introduced when subtree was changed to use `sh` instead of `bash`, in this commit:https://github.com/git/git/commit/6912ea952bf5d1b2d21d5935d6b726bab02d8bf6#contrib/subtree/git-subtree.sh This was merged in here: https://github.com/git/git/commit/779fd737d79a3e19a1aa420c33cf1195c7e20dd7#contrib/subtree/git-subtree.sh

I verified that changing the line in question back to `#!/bin/bash` eliminates the problem.

I believe that it was caused by the fact that sh echos the "-n" in this line: https://github.com/git/git/blob/master/contrib/subtree/git-subtree.sh#L314

Note that this consequently happens when, for instance, using `git subtree push` to push the subtree to an upstream repository.

I'm using OS X 10.8.4. The problem does not occur on Ubuntu at least since Ubuntu's sh is actually dash.

Next: Lukas Fleischer
Message 1 of 3 in “subtree split prepends "-n<newline>" to commit messages on OS X”
  1. Bryan HeadJul 26, 2013
  2. Avoid using `echo -n` anywhereLukas Fleischer, Jul 27, 2013
  3. Junio C HamanoJul 29, 2013

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.