9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: ori@eigenstate.org
To: 9fans@9fans.net
Subject: [9fans] git/{diff,import}: make it easier to handle manually-asembled patch emails
Date: Sun, 22 Aug 2021 13:10:08 -0400	[thread overview]
Message-ID: <DB4EA35889931227368CB36102FBC899@eigenstate.org> (raw)

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]

diff 8c228a123fa0c6062570964011854302bbf57242 uncommitted
--- a/sys/src/cmd/git/diff
+++ b/sys/src/cmd/git/diff
@@ -26,12 +26,16 @@
                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 ''
--- a/sys/src/cmd/git/import
+++ b/sys/src/cmd/git/import
@@ -45,7 +45,7 @@
                state="body"
                next
        }
-       (state=="headers" || state=="body") && (/^diff/ || /^---[       ]*$/){
+       (state=="headers" || state=="body") && (/^diff / || /^--- /){
                state="diff"
        }
        state=="body" {


------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T403f90e3b0509704-Md1cc4902bb399c16511e2f9b
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

             reply	other threads:[~2021-08-22 17:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-22 17:10 ori [this message]
2021-08-22 17:12 ` ori
2021-08-22 17:19   ` ori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DB4EA35889931227368CB36102FBC899@eigenstate.org \
    --to=ori@eigenstate.org \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).