]> git.lizzy.rs Git - plan9front.git/commitdiff
git/{diff,import}: make it easier to handle manually-asembled patch emails
authorori@eigenstate.org <ori@eigenstate.org>
Sun, 22 Aug 2021 17:18:35 +0000 (17:18 +0000)
committerori@eigenstate.org <ori@eigenstate.org>
Sun, 22 Aug 2021 17:18:35 +0000 (17:18 +0000)
Often, people (including myself) will write emails that
can almost be applied with git/import.  This changes
git/diff and git/import so that things will generally
work even when assembling diffs by hand:

1. git/import becomes slightly more lax:

^diff ...
^--- ...

will both be detected as the start of a patch.

2.  git/diff produces the same format of diff
as git/export, starting with paths:

--- a/path/to/file
+++ b/path/to/file

which means that the 'ape/patch -p1' used
within git/import will just work.

So with this, if you send an email to the mailing list,
write up a committable description, and append the
output of git/diff to the end of the email, git/import
should just work.

[this patch was send through the mailing list using the
above procedure, and will be committed with git/import
to verify that it works as advertised]

sys/src/cmd/git/diff
sys/src/cmd/git/import

index 075ea3ee920f623297f1fbb5bd21abd0d36a3e09..64206c4a72d200fef08d8f60ab412a5f62e9517a 100644 (file)
@@ -26,12 +26,16 @@ fn lsdirty {
                git/query -c $commit HEAD | subst '^..'
 }
 
+mntgen /mnt/scratch
+bind $branch/tree/ /mnt/scratch/a
+bind . /mnt/scratch/b
+echo diff `{git/query $commit} uncommitted
 for(f in `$nl{lsdirty | sort | uniq}){
-       orig=$branch/tree/$f
-       if(! test -f $orig)
+       cd /mnt/scratch
+       if(! test -f a/$f)
                orig=/dev/null
-       if(! test -f $f)
+       if(! test -f b/$f)
                f=/dev/null
-       diff -u $orig $f
+       diff -u a/$f b/$f
 }
 exit ''
index c89d52d6b0a39af82a1a9ec54c8d18c3d3fc3b5f..1ce614a2003a0d6934ca672f58823a2908bf7487 100755 (executable)
@@ -45,7 +45,7 @@ fn apply @{
                state="body"
                next
        }
-       (state=="headers" || state=="body") && (/^diff/ || /^---[       ]*$/){
+       (state=="headers" || state=="body") && (/^diff / || /^--- /){
                state="diff"
        }
        state=="body" {