Skip to content

Commit

Permalink
Merge branch 'jc/maint-filter-branch-epoch-date'
Browse files Browse the repository at this point in the history
In 1.7.9 era, we taught "git rebase" about the raw timestamp format
but we did not teach the same trick to "filter-branch", which rolled
a similar logic on its own.  Because of this, "filter-branch" failed
to rewrite commits with ancient timestamps.

* jc/maint-filter-branch-epoch-date:
  t7003: add test to filter a branch with a commit at epoch
  date.c: Fix off by one error in object-header date parsing
  filter-branch: do not forget the '@' prefix to force git-timestamp
  • Loading branch information
gitster committed Jul 22, 2012
2 parents 31c7954 + 44b85e8 commit 9a0231b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion date.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,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] != '-'))
Expand Down
2 changes: 1 addition & 1 deletion git-filter-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion t/t7003-filter-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
13 changes: 11 additions & 2 deletions t/test-lib-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,19 @@ test_pause () {
# Both <file> and <contents> default to <message>.

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"
}
Expand Down

0 comments on commit 9a0231b

Please sign in to comment.