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

[PATCH] git-rebase--interactive.sh: LF terminate line sent to cut

From
Chris Johnsen <chris_johnsen@pobox.com>
Date
Sep 17, 2010, 14:17 UTC
Message-ID
<60d13fc6a7d5b1b08f35f91b2d90eb7c13922390.1284733059.git.chris_johnsen@pobox.com>

Some versions of cut do not cope well with lines that do not end in an LF. Add '\n' to the printf format string to ensure that the generated output ends in a LF.

I found this problem when t3404's "avoid unnecessary reset" failed due to the "rebase -i" not avoiding updating the tested timestamp.

On a Mac OS X 10.4.11 system:
    % printf '%s' 'foo bar' | /usr/bin/cut -d ' ' -f 1
    cut: stdin: Illegal byte sequence
    % printf '%s\n' 'foo bar' | /usr/bin/cut -d ' ' -f 1
    foo
Signed-off-by: Chris Johnsen <chris_johnsen@pobox.com>

--- It looks like the cut on my system is derived from FreeBSD. It is probably an old version though (possibly too old to care about).

The cut from GNU coreutils does not to have this problem, so using
it serves as a workaround.
---
 git-rebase--interactive.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index eb2dff5..834460a 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -626,7 +626,7 @@ skip_unnecessary_picks () {
 		case "$fd,$command" in
 		3,pick|3,p)
 			# pick a commit whose parent is current $ONTO -> skip
-			sha1=$(printf '%s' "$rest" | cut -d ' ' -f 1)
+			sha1=$(printf '%s\n' "$rest" | cut -d ' ' -f 1)
 			case "$(git rev-parse --verify --quiet "$sha1"^)" in
 			"$ONTO"*)
 				ONTO=$sha1
-- 
1.7.3.rc2
Next: Brandon Casey
Message 1 of 7 in “git-rebase--interactive.sh: LF terminate line sent to cut”
  1. git-rebase--interactive.sh: LF terminate line sent to cutChris Johnsen, Sep 17, 2010
  2. Brandon CaseySep 17, 2010
  3. Junio C HamanoSep 17, 2010
  4. Brandon CaseySep 17, 2010
  5. git-rebase--interactive.sh: replace cut with ${v%% *}Chris Johnsen, Sep 17, 2010
  6. Junio C HamanoSep 17, 2010
  7. Chris JohnsenSep 18, 2010

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.