From cb102b083252b575b18afa8d4b4a4b1bc1ffdf9e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 9 Jul 2012 16:53:34 -0700 Subject: filter-branch: do not forget the '@' prefix to force git-timestamp For some reason, this script reinvents, instead of refactoring the existing one in git-sh-setup, the logic to grab ident information from an existing commit; it was missed when the corresponding logic in git-sh-setup was updated with 2c733fb (parse_date(): '@' prefix forces git-timestamp, 2012-02-02). Teach the script that it is OK to have a way ancient timestamp in the commits that are being filtered. Signed-off-by: Junio C Hamano --- git-filter-branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-filter-branch.sh b/git-filter-branch.sh index 804a7f4bc9..b9cded5a28 100755 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@ -84,7 +84,7 @@ set_ident () { s/.*/GIT_'$uid'_EMAIL='\''&'\''; export GIT_'$uid'_EMAIL/p g - s/^'$lid' [^<]* <[^>]*> \(.*\)$/\1/ + s/^'$lid' [^<]* <[^>]*> \(.*\)$/@\1/ s/'\''/'\''\'\'\''/g s/.*/GIT_'$uid'_DATE='\''&'\''; export GIT_'$uid'_DATE/p -- cgit v1.2.1 From be21d167b2a819fd2b4991a395e95906b3cb176a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 12 Jul 2012 13:46:49 -0700 Subject: date.c: Fix off by one error in object-header date parsing It is perfectly OK for a valid decimal integer to begin with '9' but 116eb3a (parse_date(): allow ancient git-timestamp, 2012-02-02) did not express the range correctly. Signed-off-by: Junio C Hamano --- date.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/date.c b/date.c index bf8e088e6a..67b3d66f66 100644 --- a/date.c +++ b/date.c @@ -595,7 +595,7 @@ static int match_object_header_date(const char *date, unsigned long *timestamp, unsigned long stamp; int ofs; - if (*date < '0' || '9' <= *date) + if (*date < '0' || '9' < *date) return -1; stamp = strtoul(date, &end, 10); if (*end != ' ' || stamp == ULONG_MAX || (end[1] != '+' && end[1] != '-')) -- cgit v1.2.1 From 44b85e89d70da5ee7fc688d4a9c021f6a419b363 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 12 Jul 2012 13:51:37 -0700 Subject: t7003: add test to filter a branch with a commit at epoch Running filter-branch on a history that has a commit with timestamp at epoch used to fail, but it should have been fixed. Add test to make sure it won't break again. Signed-off-by: Junio C Hamano --- t/t7003-filter-branch.sh | 3 ++- t/test-lib.sh | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index e0227730de..4d13e10de1 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -5,7 +5,8 @@ test_description='git filter-branch' test_expect_success 'setup' ' test_commit A && - test_commit B && + GIT_COMMITTER_DATE="@0 +0000" GIT_AUTHOR_DATE="@0 +0000" && + test_commit --notick B && git checkout -b branch B && test_commit D && mkdir dir && diff --git a/t/test-lib.sh b/t/test-lib.sh index d7dfc8b0b1..f3a50d4cb3 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -335,10 +335,19 @@ test_tick () { # Both and default to . test_commit () { - file=${2:-"$1.t"} + notick= && + if test "z$1" = "z--notick" + then + notick=yes + shift + fi && + file=${2:-"$1.t"} && echo "${3-$1}" > "$file" && git add "$file" && - test_tick && + if test -z "$notick" + then + test_tick + fi && git commit -m "$1" && git tag "$1" } -- cgit v1.2.1