Re: [PATCH 08/16] t4200: use cut instead of sed

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 08/16] t4200: use cut instead of sed

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:22

Jeff King [off-list ref] writes:
Some versions of sed (like the one on Solaris) don't like to
match literal tabs, and simply print nothing. Instead, let's
use cut.
-sha1=$(sed -e 's/	.*//' .git/rr-cache/MERGE_RR)
This is a bit hard to believe.  On one of my ancient Sun box:

$ uname -a
SunOS sic.twinsun.com 5.8 Generic_117350-45 sun4u sparc SUNW,UltraSPARC-IIi-Engine
$ ls -l /bin/sed
-r-xr-xr-x   1 root     bin        28748 Aug  2  2005 /bin/sed

the above "sed" does not misbehave (/bin/sh does, of course, on $(...),
but that is a different story).

Re: [PATCH 08/16] t4200: use cut instead of sed

From: Jeff King <hidden>
Date: 2016-06-15 22:44:22

On Wed, Mar 12, 2008 at 09:52:18PM -0700, Junio C Hamano wrote:
quoted
Some versions of sed (like the one on Solaris) don't like to
match literal tabs, and simply print nothing. Instead, let's
use cut.
quoted
-sha1=$(sed -e 's/	.*//' .git/rr-cache/MERGE_RR)
This is a bit hard to believe.  On one of my ancient Sun box:
Ah, sorry. I tested this line by hand, found it didn't work, and
stupidly jumped to the assumption that it was the literal tab (that
being the only interesting thing in the input).

But the actual problem is that MERGE_RR lacks a trailing newline. I
don't see any code to add newlines, even though it seems possible that
we will write out several paths. So I think we need a newline here:
diff --git a/builtin-rerere.c b/builtin-rerere.c
index c607aad..e4a1dc1 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -58,7 +58,8 @@ static int write_rr(struct path_list *rr, int out_fd)
 		int length = strlen(path) + 1;
 		if (write_in_full(out_fd, rr->items[i].util, 40) != 40 ||
 		    write_in_full(out_fd, "\t", 1) != 1 ||
-		    write_in_full(out_fd, path, length) != length)
+		    write_in_full(out_fd, path, length) != length ||
+		    write_in_full(out_fd, "\n", 1) != 1)
 			die("unable to write rerere record");
 	}
 	if (commit_lock_file(&write_lock) != 0)
And unless I am missing something, rerere on multiple paths is very
broken (but that seems weird, since this code is so old).

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help