Re: [PATCH v2 3/3] gitk: Allow displaying time zones from author and commit timestamps

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

 



On Mon, 30 May 2011, Andreas Schwab wrote:
> > +		catch {set savedTZ $env(TZ)}
>                 if {[info exits env(TZ)]} {set savedTZ $env(TZ)}

That felt like a lot of noise just to save and restore an environment 
variable, but since I more or less learned Tcl just to write this patch, 
Iâll defer to your judgement of style here.

Thanks,
Anders


diff --git a/gitk b/gitk
index c77771e..6a4c8ed 100755
--- a/gitk
+++ b/gitk
@@ -11026,14 +11026,20 @@ proc formatdate {d} {
 	if {[string match {*%[zZ]*} $datetimeformat]} {
 	    if {[catch {set d [clock format [lindex $d 0] -timezone [lindex $d 1] -format $datetimeformat]}]} {
 		# Tcl < 8.5 does not support -timezone.  Emulate it by
-		# setting TZ=UnknownÂNNNN.
+		# setting TZ=UnknownÂNN:NN.
 		global env
-		catch {set savedTZ $env(TZ)}
+		if {[info exists env(TZ)]} {
+		    set savedTZ $env(TZ)
+		}
 		set zone [lindex $d 1]
 		set sign [string map {+ - - +} [string index $zone 0]]
 		set env(TZ) Unknown$sign[string range $zone 1 2]:[string range $zone 3 4]
 		set d [clock format [lindex $d 0] -format $datetimeformat]
-		if {[catch {set env(TZ) $savedTZ}]} {unset env(TZ)}
+		if {[info exists savedTZ]} {
+		    set env(TZ) $savedTZ
+		} else {
+		    unset env(TZ)
+		}
 	    }
 	} else {
 	    set d [clock format [lindex $d 0] -format $datetimeformat]
--
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]