X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-am.sh;h=f43a75b04bf692b9ff6acaae0f6bbe51369aa399;hb=bd193f46b70fd3f8a55e2a8dcbb1fb2b4eec13d6;hp=016b5056eb29fb24d06667c340ad372ed096d4dc;hpb=7b51c33b376d22195dba1c4e067180164fd35dbf;p=git.git diff --git a/git-am.sh b/git-am.sh index 016b5056e..f43a75b04 100755 --- a/git-am.sh +++ b/git-am.sh @@ -201,7 +201,7 @@ check_patch_format () { l1= while test -z "$l1" do - read l1 + read l1 || break done read l2 read l3 @@ -311,6 +311,40 @@ split_patches () { this= msgnum= ;; + hg) + this=0 + for hg in "$@" + do + this=$(( $this + 1 )) + msgnum=$(printf "%0${prec}d" $this) + # hg stores changeset metadata in #-commented lines preceding + # the commit message and diff(s). The only metadata we care about + # are the User and Date (Node ID and Parent are hashes which are + # only relevant to the hg repository and thus not useful to us) + # Since we cannot guarantee that the commit message is in + # git-friendly format, we put no Subject: line and just consume + # all of the message as the body + perl -M'POSIX qw(strftime)' -ne 'BEGIN { $subject = 0 } + if ($subject) { print ; } + elsif (/^\# User /) { s/\# User/From:/ ; print ; } + elsif (/^\# Date /) { + my ($hashsign, $str, $time, $tz) = split ; + $tz = sprintf "%+05d", (0-$tz)/36; + print "Date: " . + strftime("%a, %d %b %Y %H:%M:%S ", + localtime($time)) + . "$tz\n"; + } elsif (/^\# /) { next ; } + else { + print "\n", $_ ; + $subject = 1; + } + ' <"$hg" >"$dotest/$msgnum" || clean_abort + done + echo "$this" >"$dotest/last" + this= + msgnum= + ;; *) if test -n "$patch_format" then @@ -496,7 +530,6 @@ else echo "$sign" >"$dotest/sign" echo "$utf8" >"$dotest/utf8" echo "$keep" >"$dotest/keep" - echo "$keepcr" >"$dotest/keepcr" echo "$scissors" >"$dotest/scissors" echo "$no_inbody_headers" >"$dotest/no_inbody_headers" echo "$GIT_QUIET" >"$dotest/quiet" @@ -542,12 +575,6 @@ if test "$(cat "$dotest/keep")" = t then keep=-k fi -case "$(cat "$dotest/keepcr")" in -t) - keepcr=--keep-cr ;; -f) - keepcr=--no-keep-cr ;; -esac case "$(cat "$dotest/scissors")" in t) scissors=--scissors ;;