{"thread":{"id":"1277","subject":"[PATCH] format-patch: --mbox and --check.","startedAt":"2005-07-20T22:37:19Z","lastAt":"2005-07-20T22:37:19Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"6281","messageId":"7v4qapf6jk.fsf@assigned-by-dhcp.cox.net","threadId":"1277","inReplyTo":"7vpstdf6rr.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] format-patch: --mbox and --check.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-20T22:37:19Z","receivedAt":"2005-07-20T22:37:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Add --mbox option to export patches in a format resembling UNIX\nmbox, so that later they can be concatenated and fed to\napplymbox.\n\nAdd --check to look for lines that introduce bogus whitespaces.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n git-format-patch-script |   49 +++++++++++++++++++++++++++++++++++++++++------\n 1 files changed, 43 insertions(+), 6 deletions(-)\n\nb9d503a8a5e3d83059836c939a09d5f6abdf5406\ndiff --git a/git-format-patch-script b/git-format-patch-script\n--- a/git-format-patch-script\n+++ b/git-format-patch-script\n@@ -4,7 +4,7 @@\n #\n \n usage () {\n-    echo >&2 \"usage: $0\"' [-n] [-o dir] [-<diff options>...] upstream [ our-head ]\n+    echo >&2 \"usage: $0\"' [-n] [-o dir] [--mbox] [--check] [-<diff options>...] upstream [ our-head ]\n \n Prepare each commit with its patch since our-head forked from upstream,\n one file per patch, for e-mail submission.  Each output file is\n@@ -16,6 +16,10 @@ the current working directory.\n \n When -n is specified, instead of \"[PATCH] Subject\", the first line is formatted\n as \"[PATCH N/M] Subject\", unless you have only one patch.\n+\n+When --mbox is specified, the output is formatted to resemble\n+UNIX mailbox format, and can be concatenated together for processing\n+with applymbox.\n '\n     exit 1\n }\n@@ -25,13 +29,19 @@ IFS='\n '\n LF='\n '\n-outdir=./\n \n+outdir=./\n while case \"$#\" in 0) break;; esac\n do\n     case \"$1\" in\n+    -a|--a|--au|--aut|--auth|--autho|--author)\n+    author=t ;;\n+    -c|--c|--ch|--che|--chec|--check)\n+    check=t ;;\n     -d|--d|--da|--dat|--date)\n     date=t ;;\n+    -m|--m|--mb|--mbo|--mbox)\n+    date=t author=t mbox=t ;;\n     -n|--n|--nu|--num|--numb|--numbe|--number|--numbere|--numbered)\n     numbered=t ;;\n     -o=*|--o=*|--ou=*|--out=*|--outp=*|--outpu=*|--output=*|--output-=*|\\\n@@ -71,6 +81,7 @@ trap 'rm -f $tmp-*' 0 1 2 3 15\n \n series=$tmp-series\n commsg=$tmp-commsg\n+filelist=$tmp-files\n \n titleScript='\n \t/./d\n@@ -115,16 +126,27 @@ do\n \n     file=`printf '%04d-%stxt' $i \"$title\"`\n     i=`expr \"$i\" - 1`\n-    echo \"$file\"\n+    echo >&2 \"* $file\"\n     {\n \tmailScript='\n \t/./d\n \t/^$/n\n-\ts|^\\[PATCH[^]]*\\] *||\n-\ts|^|[PATCH'\"$num\"'] |'\n+\ts|^\\[PATCH[^]]*\\] *||'\n+\n+\tcase \"$mbox\" in\n+\tt)\n+\t    echo 'From nobody Mon Sep 17 00:00:00 2001' ;# UNIX \"From\" line\n+\t    mailScript=\"$mailScript\"'\n+\t    s|^|Subject: [PATCH'\"$num\"'] |'\n+\t    ;;\n+\t*)\n+\t    mailScript=\"$mailScript\"'\n+\t    s|^|[PATCH'\"$num\"'] |'\n+\t    ;;\n+\tesac\n \n \teval \"$(sed -ne \"$whosepatchScript\" $commsg)\"\n-\ttest \"$au\" = \"$me\" || {\n+\ttest \"$author,$au\" = \",$me\" || {\n \t\tmailScript=\"$mailScript\"'\n \ta\\\n From: '\"$au\"\n@@ -147,5 +169,20 @@ Date: '\"$ad\"\n \tgit-diff-tree -p $diff_opts \"$commit\" | git-apply --stat --summary\n \techo\n \tgit-diff-tree -p $diff_opts \"$commit\" | sed -e \"$stripCommitHead\"\n+\n+\tcase \"$mbox\" in\n+\tt)\n+\t\techo\n+\t\t;;\n+\tesac\n     } >\"$outdir$file\"\n+    case \"$check\" in\n+    t)\n+\t# This is slightly modified from Andrew Morton's Perfect Patch.\n+\t# Lines you introduce should not have trailing whitespace.\n+\t# Also check for an indentation that has SP before a TAB.\n+        grep -n '^+\\([ \t]* \t.*\\|.*[ \t]\\)$' \"$outdir$file\"\n+\n+\t: do not exit with non-zero because we saw no problem in the last one.\n+    esac\n done <$series\n"}]}