From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <9front-bounces@9front.inri.net> X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from 9front.inri.net (9front.inri.net [168.235.81.73]) by inbox.vuxu.org (Postfix) with ESMTP id 4FC8A21516 for ; Mon, 5 Aug 2024 08:28:29 +0200 (CEST) Received: from mimir.eigenstate.org ([206.124.132.107]) by 9front; Mon Aug 5 02:26:24 -0400 2024 Received: from mimir.eigenstate.org (localhost [127.0.0.1]) by mimir.eigenstate.org (OpenSMTPD) with ESMTP id 8b0bf95f for <9front@9front.org>; Sun, 4 Aug 2024 23:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=eigenstate.org; h= message-id:to:subject:date:from:mime-version:content-type :content-transfer-encoding; s=mail; bh=WZ8+IHc5PaovM9Kq3rHspi7fR XI=; b=nQxkEZEq/8q3cUl8ckYDsGHD/X/BLVkN5+VTdh9fhcRq7AS76OT8olrdi HQjZkzxDnlFuhXACr3eZTdHriRdh13sr5agLXFaWCCtn8xECFISYg7pfFLH0nec7 ss2WRg0Fse66B5CF63KKxUCcgxxLDZEVL+T4txQzDXYeeguKzk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=eigenstate.org; h=message-id :to:subject:date:from:mime-version:content-type :content-transfer-encoding; q=dns; s=mail; b=XsjNG272mtsP6VXU8rI VTgyzpjNKQPO6fjYoohqwxhfAqfwkv6AhmBB79hi3fj/hfkjxnMAT+aeNueeaj9C o6MuNjux7e0VlTcwjPwT5kyJDHA43zRxcHQIcZV1/nlmSbT8hywY8KD65CjFlXqD CnT5o7BVdwYeV5BkmMfudvFY= Received: from chainsaw.dev ( [172.58.27.41]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id b13818e2 (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO) for <9front@9front.org>; Sun, 4 Aug 2024 23:26:21 -0700 (PDT) Message-ID: <4C539264EE17F49630F4A09810EE9E53@eigenstate.org> To: 9front@9front.org Date: Mon, 05 Aug 2024 02:23:38 -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: overflow-preventing flexible self-signing blockchain Subject: [9front] diff: request for some eyeballs/testing Reply-To: 9front@9front.org Precedence: bulk as a result of the recent 1oct1993 changes, I discovered we don't currently handle file->dir changes correctly in a bunch of our utilities; diff, patch, and git are all a tad wonky when it comes to this. the first, er, diff to diff which should start helping fix this is below -- it fixes both path construction and makes it print a file deletion and addition when a directory is involved in the diff; patch should then have sufficient info to apply the diff (though it currently doesn't handle it correctly). this fixes diff mis-constructing file paths, diff 4c6701041ec241bbb900883043790af2fd5e8152 uncommitted --- a/sys/src/cmd/diff/diffdir.c +++ b/sys/src/cmd/diff/diffdir.c @@ -19,14 +19,14 @@ int nitems; int fd, n; - if ((fd = open(name, OREAD)) < 0) { + cp = emalloc(sizeof(char*)); + cp[0] = nil; + if(strcmp(name, "/dev/null") == 0) + return cp; + if((fd = open(name, OREAD)) < 0){ fprint(2, "%s: can't open %s: %r\n", argv0, name); - /* fake an empty directory */ - cp = emalloc(sizeof(char*)); - cp[0] = 0; return cp; } - cp = 0; nitems = 0; if((n = dirreadall(fd, &db)) > 0){ while (n--) { @@ -44,18 +44,6 @@ return cp; } -static int -isdotordotdot(char *p) -{ - if (*p == '.') { - if (!p[1]) - return 1; - if (p[1] == '.' && !p[2]) - return 1; - } - return 0; -} - void diffdir(char *f, char *t, int level) { @@ -68,17 +56,11 @@ dt = scandir(t); dirf = df; dirt = dt; + if(level != 0 && !rflag) + return; while (*df || *dt) { from = *df; to = *dt; - if (from && isdotordotdot(from)) { - df++; - continue; - } - if (to && isdotordotdot(to)) { - dt++; - continue; - } if (!from) res = 1; else if (!to) @@ -86,23 +68,30 @@ else res = strcmp(from, to); if (res < 0) { - if (mode == 0 || mode == 'n') + if (mkpathname(fb, f, from)) + continue; + if(rflag) + diff(fb, "/dev/null", level+1); + else if(mode == 0 || mode == 'n') Bprint(&stdout, "Only in %s: %s\n", f, from); df++; - continue; - } - if (res > 0) { + }else if (res > 0){ + if (mkpathname(tb, t, to)) + continue; + if(rflag) + diff("/dev/null", tb, level+1); if (mode == 0 || mode == 'n') Bprint(&stdout, "Only in %s: %s\n", t, to); dt++; - continue; + }else{ + if (mkpathname(fb, f, from)) + continue; + if (mkpathname(tb, t, to)) + continue; + diff(fb, tb, level+1); + df++; + dt++; } - if (mkpathname(fb, f, from)) - continue; - if (mkpathname(tb, t, to)) - continue; - diff(fb, tb, level+1); - df++; dt++; } for (df = dirf; *df; df++) free(*df); @@ -115,7 +104,7 @@ void diff(char *f, char *t, int level) { - char *fp, *tp, *p, fb[MAXPATHLEN+1], tb[MAXPATHLEN+1]; + char *fp, *tp; Dir *fsb, *tsb; fsb = nil; @@ -129,24 +118,15 @@ diffdir(fp, tp, level); else Bprint(&stdout, "Common subdirectories: %s and %s\n", fp, tp); - } - else if (REGULAR_FILE(fsb) && REGULAR_FILE(tsb)) + }else if (REGULAR_FILE(fsb) && REGULAR_FILE(tsb)){ diffreg(fp, f, tp, t); - else { - if (REGULAR_FILE(fsb)) { - if ((p = utfrrune(f, '/')) == 0) - p = f; - else - p++; - if (mkpathname(tb, tp, p) == 0) - diffreg(fp, f, tb, t); - } else { - if ((p = utfrrune(t, '/')) == 0) - p = t; - else - p++; - if (mkpathname(fb, fp, p) == 0) - diffreg(fb, f, tp, t); + }else{ + if(REGULAR_FILE(fsb)){ + diffreg(fp, f, "/dev/null", "/dev/null"); + diffdir("/dev/null", tp, level); + }else{ + diffdir(fp, "/dev/null", level); + diffreg("/dev/null", "/dev/null", tp, t); } } Return: