#578915 git-svn: git svn log differs slightly from svn log in date formatting

#578915#5
Date:
2010-04-23 13:46:12 UTC
From:
To:
Hi,

since it is possible that the commit log of a Subversion repository is
changed I want to compare my git log with the svn log:

svn log > svn.log
git svn log > git.log

Both files differ slightly:

git:
r2105 | viktor | 2010-03-19 13:40:54 +0100 (Fr, 19 Mär 2010) | 2 lines

svn:
r2105 | viktor | 2010-03-19 13:40:54 +0100 (Fr, 19. Mär 2010) | 1 Zeile

First of all the dot after the day of month is missing in the German locale.
The dot stands for an ordinal number (e.g. "19." == "19th").
Second: "line(s)" is not translated. I can workaround by starting git/svn in an
English locale ...
Third: the git log often contains an addional empty line.

Please synchronize the output. Thanks.

Jens

#578915#10
Date:
2010-04-26 13:27:10 UTC
From:
To:
tags 578915 + upstream
thanks

Hi Jens,

Jens Seidel wrote:

As a silly workaround, I’d suggest coming up with a substitution to make
them look the same.  For example, you could remove all strings in
parentheses.

Care to write a patch?  This sounds like a useful change, but realistically
speaking, I do not see anyone working on it soon.  I’d be glad to help in
any way I can (pointing to relevant functions and so on).

Thanks for the report,
Jonathan

#578915#17
Date:
2010-04-27 11:26:56 UTC
From:
To:
Hi Jonathan,

yep, one has to apply a filter, also to remove the addional empty lines (and
non matching spaces at end of lines).

Ah, git svn ignores any locale, this explains the problem.

I tried to fix both.

This remains open. Probably that can be solved by setting a git config
option and resyncing all git svn history from git.
Please note that I don't know Perl. Please check my changes very carefully!
--- /usr/lib/git-core/git-svn.orig	2010-04-11 19:14:03.000000000 +0200
+++ /usr/lib/git-core/git-svn	2010-04-27 12:50:51.000000000 +0200
@@ -50,6 +50,7 @@
 use Carp qw/croak/;
 use Digest::MD5;
 use IO::File qw//;
+use Locale::gettext;

Let's use the gettext system which is also used by Subversion and is the
quasi standard for translations. I hope this doesn't increase the
dependencies of git-svn.

@@ -5492,7 +5495,8 @@
 	my $gm = timelocal(gmtime($t));
 	my $sign = qw( + + - )[ $t <=> $gm ];
 	my $gmoff = sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[2,1]);
-	return strftime("%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)", localtime($t));
+	my $d = Locale::gettext->domain("subversion");

I'm not sure whether it is efficient to perform this call here. Maybe it
should be a (global???) variable. Let's reuse existing Subversion
translations (why not -?)).

+	return strftime("%Y-%m-%d %H:%M:%S $gmoff" . $d->get(" (%a, %d %b %Y)"), localtime($t));

Only the last part can be changed by translators in Subversion. See trunk,
file libsvn_subr/time.c:

/* Machine parseable part, generated by apr_snprintf. */
#define HUMAN_TIMESTAMP_FORMAT "%.4d-%.2d-%.2d %.2d:%.2d:%.2d %+.2d%.2d"
/* Human explanatory part, generated by apr_strftime as "Sat, 01 Jan 2000"
 * */
#define human_timestamp_format_suffix _(" (%a, %d %b %Y)")

@@ -5598,20 +5603,15 @@
 		}
 		$nr_line = scalar @$l;
 		if (!$nr_line) {
-			print "1 line\n\n\n";
+			print sprintf($d->nget(" | %d line", " | %d lines", 1), 1), "\n\n\n";


Please put
 sprintf($d->nget(" | %d line", " | %d lines", n), n)
into a function (which integer parameter n) to avoid code duplication. The
first n selects the string to be used (the singular or plural form), the
second replaces %d by the number.

Since Subversion has the string " | %d line" translated, we have to match
it (and cannot request the translation for "line").

I tried it and it works well.

Jens

#578915#22
Date:
2010-04-27 14:29:12 UTC
From:
To:
tags 578915 + patch
quit

Hi Jens,

Jens Seidel wrote:

Thank you!  I will try this out a little and look it over later today.

You write pretty clear code for someone who doesn’t know Perl.
I am guessing this will be fine.

Thanks,
Jonathan

#578915#29
Date:
2010-08-20 04:24:09 UTC
From:
To:
forwarded 578915 http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/698398/focus=151774
quit

Jens Seidel wrote:

Thanks!  For reference when returning to this, I'm marking the latest
patch as the current "forwarded" address.