Web lists-archives.com

git svn fetch --localtime produces wrong commit times




In converting a SVN repository to git, the commit timestamp is
generated incorrectly.  I use "git svn fetch --localtime" and the
offset from UTC is always set to +0200 (probably because that is the
current local offset here, i.e. Europe/Berlin) even for times when it
should be +0100.

For example, in my SVN working copy I get

    $ svn log -r152
    ------------------------------------------------------------------------
    r152 | urs | 2010-08-16 11:05:52 +0200 (Mon, 16 Aug 2010) | 2 lines

    Add error checks on input file streams

    ------------------------------------------------------------------------
    $ svn log -r158
    ------------------------------------------------------------------------
    r158 | urs | 2010-11-24 00:24:13 +0100 (Wed, 24 Nov 2010) | 16 lines

    Make code portable to Linux/amd64

After converting to git using

    $ mkdir use
    $ cd use
    $ git svn init -s file://$HOME/SVN/use
    Initialized empty Git repository in /home/urs/GIT/use/.git/
    $ git svn fetch -q -A ../ADM/git.svn-authors --localtime
    r1 = 12cb83315be96e594a98b42db7ae57d19e0c7973 (refs/remotes/origin/trunk)
    ...
    r162 = 99ff393f1d64f330b14d6e06412b94fd3023d616 (refs/remotes/origin/trunk)
    Checked out HEAD:
      file:///home/urs/SVN/use/trunk r162

I see wrong commit timestamps:

    $ git log
    ...
    commit c6b4f7aaa66650a16de67d32fb83d541b1973331
    Author: Urs Thuermann <urs@xxxxxxxxxxxxxxxxx>
    Date:   Wed Nov 24 00:24:13 2010 +0200

        Make code portable to Linux/amd64


        git-svn-id: file:///home/urs/SVN/use/trunk@158 b3714422-7cff-11dd-9a33-b89007e0d947
    ...
    commit a9d95e506681ac5742d2d0927c93f22c541ff170
    Author: Urs Thuermann <urs@xxxxxxxxxxxxxxxxx>
    Date:   Mon Aug 16 11:05:52 2010 +0200

        Add error checks on input file streams


        git-svn-id: file:///home/urs/SVN/use/trunk@152 b3714422-7cff-11dd-9a33-b89007e0d947
    ...

In revision 152 the timestamp is correct, but for revision 158 the UTC
offset is +0200 instead of +0100.  Then, of course, also the POSIX
timestamp in the commit object is wrong:

    $ git cat-file -p c6b4f7aaa66650a16de67d32fb83d541b1973331
    tree ff4528220ddcf8beca9f4958fbb947d5ed85808e
    parent edcaeb292153663664d850bafe1dad12daab4165
    author Urs Thuermann <urs@xxxxxxxxxxxxxxxxx> 1290551053 +0200
    committer Urs Thuermann <urs@xxxxxxxxxxxxxxxxx> 1290551053 +0200

        Make code portable to Linux/amd64
    ...
    $ date -d@1290551053 +%F\ %T\ %z
    2010-11-23 23:24:13 +0100

The correct timestamp would be 2010-11-24 00:24:13 +0100, or, as a
POSIX time_t 1290554653.

I could find the bug grepping through /usr/lib/git-core/git-svn, maybe
it's in GIT::SVN::Fetcher or some other GIT::SVN module.

Is a fix available for this bug?

urs