From 861f00e3496fd5cd866a73f11826dfc8822a5195 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 30 Apr 2008 00:13:58 -0400 Subject: [PATCH 1/2] fix reflog approxidate parsing bug In get_sha1_basic, we parse a string like HEAD@{10 seconds ago}:path/to/file into its constituent ref, reflog date, and path components. We never actually munge the string itself, but instead keep offsets into the string with their associated lengths. When we call approxidate on the contents inside braces, however, we pass just a string without a length. This means that approxidate could sometimes look past the closing brace and (erroneously) interpret the rest of the string as part of the date. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- sha1_name.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sha1_name.c b/sha1_name.c index 6c9c1c75ad..6298c37ae3 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -352,8 +352,11 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1) } if (0 <= nth) at_time = 0; - else - at_time = approxidate(str + at + 2); + else { + char *tmp = xstrndup(str + at + 2, reflog_len); + at_time = approxidate(tmp); + free(tmp); + } if (read_ref_at(real_ref, at_time, nth, sha1, NULL, &co_time, &co_tz, &co_cnt)) { if (at_time) From b3bb5f76e6193db102b063187be854ef3842d89b Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 30 Apr 2008 00:36:14 -0400 Subject: [PATCH 2/2] cvsimport: always pass user data to "system" as a list This avoids invoking the shell. Not only is it faster, but it prevents the possibility of interpreting our arguments in the shell. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 8093996e25..33777e2785 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -767,7 +767,7 @@ sub commit { waitpid($pid,0); die "Error running git-commit-tree: $?\n" if $?; - system("git-update-ref $remote/$branch $cid") == 0 + system('git-update-ref', "$remote/$branch", $cid) == 0 or die "Cannot write branch $branch for update: $!\n"; if ($tag) {