git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Handle "git show" output correctly.
@ 2012-09-12 15:26 Peter Jones
  2012-09-12 15:30 ` Peter Jones
  2012-09-12 15:40 ` Matthieu Moy
  0 siblings, 2 replies; 21+ messages in thread
From: Peter Jones @ 2012-09-12 15:26 UTC (permalink / raw)
  To: git; +Cc: Peter Jones

Signed-off-by: Peter Jones <pjones@redhat.com>
---
 git-am.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/git-am.sh b/git-am.sh
index c682d34..ebcbff7 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -216,6 +216,21 @@ check_patch_format () {
 		read l2
 		read l3
 		case "$l1" in
+                "commit "*)
+                        case "$l2" in
+                        "Author: "*)
+                                case "$l3" in
+                                "Date: "*)
+                                        patch_format=gitshow
+                                        ;;
+                                *)
+                                        ;;
+                                esac
+                                ;;
+                        *)
+                                ;;
+                        esac
+                        ;;
 		"From "* | "From: "*)
 			patch_format=mbox
 			;;
@@ -321,6 +336,37 @@ split_patches () {
 		this=
 		msgnum=
 		;;
+        gitshow)
+		this=0
+		for stgit in "$@"
+		do
+			this=`expr "$this" + 1`
+			msgnum=`printf "%0${prec}d" $this`
+			# Perl version of The first nonemptyline after an
+                        # empty line is the subject, and the body starts with
+                        # the next nonempty line.
+			perl -ne 'BEGIN { $subject = 0 }
+				if ($subject > 1) { print ; }
+				elsif (/^\s+$/) { next ; }
+				elsif (/^Author:/) { s/Author/From/ ; print ;}
+				elsif (/^(From|Date)/) { print ; }
+                                elsif (/^commit/) { next ; }
+				elsif ($subject) {
+					$subject = 2 ;
+					print "\n" ;
+                                        s/^    // ;
+					print ;
+				} else {
+					print "Subject: ", $_ ;
+					$subject = 1;
+				}
+			' < "$stgit" > "$dotest/$msgnum" || clean_abort
+		done
+		echo "$this" > "$dotest/last"
+		this=
+		msgnum=
+		;;
+
 	hg)
 		this=0
 		for hg in "$@"
-- 
1.7.11.4

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2012-09-12 23:05 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-12 15:26 [PATCH] Handle "git show" output correctly Peter Jones
2012-09-12 15:30 ` Peter Jones
2012-09-12 15:41   ` Matthieu Moy
2012-09-12 15:49     ` [PATCH] [git-am] " Peter Jones
2012-09-12 15:57       ` Matthieu Moy
2012-09-12 17:32         ` Junio C Hamano
2012-09-12 18:05           ` Peter Jones
2012-09-12 19:07             ` Junio C Hamano
2012-09-12 15:42   ` [PATCH] " Peter Jones
2012-09-12 15:40 ` Matthieu Moy
2012-09-12 18:00   ` Peter Jones
2012-09-12 18:08     ` [PATCH] git-am: " Peter Jones
2012-09-12 20:06       ` Junio C Hamano
2012-09-12 20:48         ` Peter Jones
2012-09-12 21:03           ` Peter Jones
2012-09-12 21:18           ` Junio C Hamano
2012-09-12 21:26             ` Dan Johnson
2012-09-12 22:19               ` Junio C Hamano
2012-09-12 22:31                 ` Dan Johnson
2012-09-12 23:05                   ` Junio C Hamano
2012-09-12 22:41                 ` Andreas Ericsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).