git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git svn fetch --localtime produces wrong commit times

From
Urs Thuermann <urs@isnogud.escape.de>
Date
Aug 2, 2017, 14:36 UTC
Message-ID
<ygf8tj26npy.fsf@tehran.isnogud.escape.de>

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@isnogud.escape.de>
    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@isnogud.escape.de>
    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@isnogud.escape.de> 1290551053 +0200
    committer Urs Thuermann <urs@isnogud.escape.de> 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
Next: Urs Thuermann
Message 1 of 2 in “git svn fetch --localtime produces wrong commit times”
  1. Urs ThuermannAug 2, 2017
  2. Urs ThuermannAug 2, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.