diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2007-02-06 14:58:30 -0500 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2007-02-06 14:58:30 -0500 |
commit | 63e0c8b364e334fc7cc975edf1f16fb4c89594b3 (patch) | |
tree | 85f4ed7849cf2799bb1dbcd0b696415f4b748d6a /t | |
parent | ef94edb53c9a5fd1e5fca9f548adc713d3d8ffe1 (diff) | |
download | git-63e0c8b364e334fc7cc975edf1f16fb4c89594b3.tar.gz git-63e0c8b364e334fc7cc975edf1f16fb4c89594b3.tar.xz |
Support RFC 2822 date parsing in fast-import.
Since some frontends may be working with source material where
the dates are only readily available as RFC 2822 strings, it is
more friendly if fast-import exposes Git's parse_date() function
to handle the conversion. This way the frontend doesn't need
to perform the parsing itself.
The new --date-format option to fast-import can be used by a
frontend to select which format it will supply date strings in.
The default is the standard `raw` Git format, which fast-import
has always supported. Format rfc2822 can be used to activate the
parse_date() function instead.
Because fast-import could also be useful for creating new, current
commits, the format `now` is also supported to generate the current
system timestamp. The implementation of `now` is a trivial call
to datestamp(), but is actually a whole whopping 3 lines so that
fast-import can verify the frontend really meant `now`.
As part of this change I have added validation of the `raw` date
format. Prior to this change fast-import would accept anything
in a `committer` command, even if it was seriously malformed.
Now fast-import requires the '> ' near the end of the string and
verifies the timestamp is formatted properly.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 't')
-rwxr-xr-x | t/t9300-fast-import.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index a5cc846b3..84b3c12a5 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -240,4 +240,40 @@ test_expect_success \ 'git-cat-file blob branch:newdir/exec.sh >actual && diff -u expect actual' +### +### series E +### + +cat >input <<INPUT_END +commit refs/heads/branch +author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500 +data <<COMMIT +RFC 2822 type date +COMMIT + +from refs/heads/branch^0 + +INPUT_END +test_expect_failure \ + 'E: rfc2822 date, --date-format=raw' \ + 'git-fast-import --date-format=raw <input' +test_expect_success \ + 'E: rfc2822 date, --date-format=rfc2822' \ + 'git-fast-import --date-format=rfc2822 <input' +test_expect_success \ + 'E: verify pack' \ + 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done' + +cat >expect <<EOF +author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500 + +RFC 2822 type date +EOF +test_expect_success \ + 'E: verify commit' \ + 'git-cat-file commit branch | sed 1,2d >actual && + diff -u expect actual' + test_done |