ref: 12407c20b7b6788307cbbea0251e4f2f338d629b
parent: c188c740ec6629d3915864ea11d6bbade5598e30
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Dec 2 21:57:38 EST 2020
import, export: fix patch formatting Git uses '---' to separate the message from the patch. We used to, but we were buggy about it -- and then a recent patch broke it entirely. This reverts and fixes the previous behavior, so that git/export > /tmp/patch git/branch -nb HEAD~ master git/import /tmp/patch will round trip properly, and produce the same commit id. This makes it easier to send around patches, since applying a patch will not cause conflicts. It should also make for a nicer git/rebase.
--- a/export
+++ b/export
@@ -36,20 +36,17 @@
echo From $c
echo From: `{cat $cp/author}
- echo Date: `{date -m `{mtime $cp/author | awk '{print $1}'}}
+ echo Date: `{date -um `{mtime $cp/author | awk '{print $1}'}}
<$cp/msg awk '
- BEGIN {RS = ""; FS = "\n"}
NR == 1 {
n = ENVIRON["n"]
m = ENVIRON["m"]
+ msg=$0
if(m > 1)
patch = sprintf("[PATCH %d/%d]", n, m)
else
patch = "[PATCH]"
- printf "Subject: %s", patch
- for(i = 1; i <= NF; i++)
- msg = msg " " $i
- printf "%s\n\n", msg
+ printf "Subject: %s %s\n\n", patch, msg
gsub("^[ ]|[ ]$", "", msg)
gsub("[/ ]", "-", msg)
@@ -56,7 +53,11 @@
printf "%.4d-%s.patch", n, msg >ENVIRON["patchname"]
next
}
- {print; printf "\n"}'
+ {
+ }'
+ echo '---'
+ echo diff `{basename $pp} `{basename $cp}
for(f in $fc){
a=a/$f
if(! test -e $a)
--- a/import
+++ b/import
@@ -45,14 +45,10 @@
state="body"
next
}
- (state=="headers" || state=="body") && (/^diff/ || /^---[ ].*$/){
+ (state=="headers" || state=="body") && (/^diff/ || /^---[ ]*$/){
state="diff"
}
state=="body" {
- if(didthis == 0){
- printf "\n" > "/env/msg"
- didthis = 1
- }
print > "/env/msg"
}
state=="diff" {