Re: [PATCH/WIP] git-svn: tweak log format to match "svn log" output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jonathan Nieder <jrnieder@xxxxxxxxx> wrote:
> From: Jens Seidel <jensseidel@xxxxxxxxxxxx>
> 
> Tweak "git svn log" output to more closely match what svn produces.
> In particular, if Locale::gettext is available, use that to produce
> localized output using svn’s translations.

<snip>

> [jn: made Locale::gettext dependency optional; added a test script]
> 
> Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
> ---
> Jens Seidel wrote at http://bugs.debian.org/578915:
> >> Jens Seidel wrote:
> 
> > Ah, git svn ignores any locale, this explains the problem.
> >
> >>> 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 ...
> >
> > I tried to fix both.
> >
> >>> Third: the git log often contains an addional empty line.
>
> > This remains open. Probably that can be solved by setting a git config
> > option and resyncing all git svn history from git.

Hi Jens, Jonathan,

I just made an additional patch that should solve the problem
(see my reply to this email).

> Sorry to leave this hanging for so long.  I think it is an improvement
> as is, but I have not tested in the following scenarios:
> 
>  - Locale::gettext not available
>  - subversion not translated
>  - subversion translated but not to the current language
> 
> And the extra blank line at the end of log messages remains unsolved.
> 
> Thoughts?

Everything looks reasonable to me.  gettext should just fall back to the
original string when a translation is not available.

I've squashed the following cleanup on top of Jens' original change:

diff --git a/git-svn.perl b/git-svn.perl
index 55dc50d..5252722 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -5536,14 +5536,12 @@ sub format_svn_date {
 	my $gm = timelocal(gmtime($t));
 	my $sign = qw( + + - )[ $t <=> $gm ];
 	my $gmoff = sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[2,1]);
-	my $format;
+	my $format = " (%a, %d %b %Y)";
 	if ($can_localize) {
 		my $d = Locale::gettext->domain("subversion");
-		$format = "%Y-%m-%d %H:%M:%S $gmoff" . $d->get(" (%a, %d %b %Y)");
-	} else {
-		$format = "%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)";
+		$format = $d->get($format);
 	}
-	return strftime($format, localtime($t));
+	return strftime("%Y-%m-%d %H:%M:%S $gmoff$format", localtime($t));
 }
 
 sub parse_git_date {
@@ -5646,8 +5644,8 @@ sub show_commit_normal {
 
 	if ($can_localize) {
 		my $d = Locale::gettext->domain("subversion");
-		$sing_fmt = $d->nget(" | %d line", " | %d lines", 1);
-		$plur_fmt = $d->nget(" | %d line", " | %d lines", 10);
+		$sing_fmt = $d->nget($sing_fmt, $plur_fmt, 1);
+		$plur_fmt = $d->nget($sing_fmt, $plur_fmt, 10);
 	}
 	if (my $l = $c->{l}) {
 		while ($l->[$#$l] eq "\n" && $#$l > 0
-- 
Eric Wong
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]