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 BF842289DF for ; Mon, 5 Aug 2024 08:48:34 +0200 (CEST) Received: from mimir.eigenstate.org ([206.124.132.107]) by 9front; Mon Aug 5 02:47:18 -0400 2024 Received: from mimir.eigenstate.org (localhost [127.0.0.1]) by mimir.eigenstate.org (OpenSMTPD) with ESMTP id 22983567 for <9front@9front.org>; Sun, 4 Aug 2024 23:47:15 -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=aRIVNAfr+TT//Z4n4zpvAiyOR oc=; b=IQRgnms3aEUALuDcEKj+VsDWn/vNMRHywhsPI+pYiJrv8hl0guAeEzA8y XlHYs3R900v0Nev/ROFmMjLK3nP5zPmIt3mig1d5+9L8hwPNNtVlygrj5qdz682+ LisSNf1IAHAkOIQxIWByqB8zu+znw+qxjF4lZqHPvJ2YKAPMkA= 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=ANI4ZOzFErnbClfp2zH qi6DlTaNrzullUqY2BYYrEPdA5sXC6dXx9I65HaM6t/nIfso3HkeXEASnR2QNjDQ zSmXhVUq3w4lhQU4ZxYsHM710468VLNtN76OsbyZ9bFnqZHntAboxHMXFJHU8R2U SUiFEYaTV990BceO+RwsXesY= Received: from chainsaw.dev ( [172.58.27.41]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id 64ca966c (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO) for <9front@9front.org>; Sun, 4 Aug 2024 23:47:14 -0700 (PDT) Message-ID: <47FCF56C2AE1929317E1F73F7D248F97@eigenstate.org> To: 9front@9front.org Date: Mon, 05 Aug 2024 02:44:29 -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: distributed callback rich-client general-purpose markup Subject: [9front] git/save: allow files to become dirs Reply-To: 9front@9front.org Precedence: bulk git code assumed that a file, once checked in, would always be a file; this changes the code to lift that assumption; again, reviews and testing would be appreciated. diff 4c6701041ec241bbb900883043790af2fd5e8152 uncommitted --- a/sys/src/cmd/git/save.c +++ b/sys/src/cmd/git/save.c @@ -243,8 +243,10 @@ for(ep = p; ep != epath; ep++){ if(strncmp(elt, *ep + off, ne) != 0) break; - if((*ep)[off+ne] != '\0' && (*ep)[off+ne] != '/') + if(!isdir && (*ep)[off+ne] != '\0') break; + if(isdir && (*ep)[off+ne] != '/') + break; } e = dirent(&ent, &nent, elt); if(e->islink) @@ -251,6 +253,7 @@ sysfatal("symlinks may not be modified: %s", *path); if(e->ismod) sysfatal("submodules may not be modified: %s", *path); + d = dirstat(*p); if(isdir){ e->mode = DMDIR | 0755; sub[nsub] = readobject(e->h); @@ -270,19 +273,17 @@ else if(n == -1) goto err; }else{ - d = dirstat(*p); - if(d != nil && tracked(*p)) + if(d != nil && !(d->mode & DMDIR) && tracked(*p)) blobify(d, *p, &e->mode, &e->h); else e->name = nil; - free(d); } + free(d); } if(nent == 0){ werrstr("%.*s: empty directory", off, *path); goto err; } - r = writetree(ent, nent, h); err: free(sub);