am: use gmtime() to parse mercurial patch date
[gitweb.git] / git-am.sh
index a67d0f98989706fa69df4cf7d6242ad9531eb337..5eec11d5f09c50a83553a8ea5ad763f0d2e44feb 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -297,6 +297,7 @@ split_patches () {
                ;;
        stgit)
                this=0
+               test 0 -eq "$#" && set -- -
                for stgit in "$@"
                do
                        this=$(expr "$this" + 1)
@@ -318,7 +319,7 @@ split_patches () {
                                        print "Subject: ", $_ ;
                                        $subject = 1;
                                }
-                       ' < "$stgit" > "$dotest/$msgnum" || clean_abort
+                       ' -- "$stgit" >"$dotest/$msgnum" || clean_abort
                done
                echo "$this" > "$dotest/last"
                this=
@@ -342,11 +343,11 @@ split_patches () {
                                elsif (/^\# User /) { s/\# User/From:/ ; print ; }
                                elsif (/^\# Date /) {
                                        my ($hashsign, $str, $time, $tz) = split ;
-                                       $tz = sprintf "%+05d", (0-$tz)/36;
+                                       $tz_str = sprintf "%+05d", (0-$tz)/36;
                                        print "Date: " .
                                              strftime("%a, %d %b %Y %H:%M:%S ",
-                                                      localtime($time))
-                                             . "$tz\n";
+                                                      gmtime($time-$tz))
+                                             . "$tz_str\n";
                                } elsif (/^\# /) { next ; }
                                else {
                                        print "\n", $_ ;