From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 25671 invoked from network); 23 Aug 2021 09:08:53 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 23 Aug 2021 09:08:53 -0000 Received: from mimir.eigenstate.org ([206.124.132.107]) by 1ess; Sun Aug 22 13:18:51 -0400 2021 Received: from abbatoir.myfiosgateway.com (pool-74-108-56-225.nycmny.fios.verizon.net [74.108.56.225]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id 590b466d (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO) for <9front@9front.org>; Sun, 22 Aug 2021 10:18:36 -0700 (PDT) Message-ID: To: 9front@9front.org Date: Sun, 22 Aug 2021 13:18:35 -0400 From: ori@eigenstate.org MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: webscale overflow-preventing firewall STM API Subject: [9front] git/{diff,import}: make it easier to handle manually-asembled patch emails Reply-To: 9front@9front.org Precedence: bulk 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" {