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.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 4220 invoked from network); 19 Apr 2022 11:28:41 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 19 Apr 2022 11:28:41 -0000 Received: from mail.9lab.org ([168.119.8.41]) by 9front; Tue Apr 19 07:27:20 -0400 2022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9lab.org; s=20210803; t=1650367631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=t7g//FX2Ikb3in1cI0v8mcZtVJwV7GkXHwj60BrrmS4=; b=qKYlYBL2xrDCjYeUfD4MI7J1gMyGmzes3upyxnGBjAfrYuzOaNsT9LAnRAwC23OBN0tsHN pLo7qH3jnQkozfNO8EJRMDH5nqQKskURRThj5yNcHzRApNgphTVA1DJGt4W5rqn27Z1AlT wZScFh7xBef2do4awN1t53sLtt5NjYE= Received: from rob.9lab.home (host-185-64-155-70.ecsnet.at [185.64.155.70]) by mail.9lab.org (OpenSMTPD) with ESMTPSA id e2545626 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Tue, 19 Apr 2022 13:27:10 +0200 (CEST) Message-ID: <16252894EB4E4869BAF9B5658115F8FF@9lab.org> To: 9front@9front.org CC: ori@eigenstate.org, igor@9lab.org Date: Tue, 19 Apr 2022 13:27:09 +0200 From: igor@9lab.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-evymxpqsmexgrtbayeunvgjskw" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: self-signing realtime-java-based element deep-learning database Subject: [9front] [PATCH] git/merge: fix merge if directory of merged file does not exist Reply-To: 9front@9front.org Precedence: bulk This is a multi-part message in MIME format. --upas-evymxpqsmexgrtbayeunvgjskw Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit When merging from branch `front` to `test` the following test case fails: term% git/init merge.fail.git term% cd merge.fail.git term% mkdir A term% cp /sys/src/cmd/xargs.c A/ term% git/add A/xargs.c term% git/commit -m 'Meh...' A/xargs.c heads/front: 5c36636e55aac3341ce42afee51b73106e8f1bc5 term% git/branch -n test refs/heads/test: 5c36636e55aac3341ce42afee51b73106e8f1bc5 term% mkdir X term% cp /sys/src/cmd/xargs.c X/ term% git/add X/xargs.c term% git/commit -m 'Nein...' X/xargs.c heads/test: 6dc8fecb03f15e1c018c51306d25b10919e8fbe4 term% git/branch front refs/heads/front: 5c36636e55aac3341ce42afee51b73106e8f1bc5 term% mkdir A/B term% cp /sys/src/cmd/xargs.c A/B/ term% git/add A/B/xargs.c term% git/commit -m 'NeinNein...' A/B/xargs.c heads/front: 3ca03f92152ed170e12b1ce2416ababbc18ffe54 term% git/branch test refs/heads/test: 6dc8fecb03f15e1c018c51306d25b10919e8fbe4 term% mkdir X/Y term% cp /sys/src/cmd/xargs.c X/Y/ term% git/add X/Y/xargs.c term% git/commit -m 'NeinNeinNein...' X/Y/xargs.c heads/test: a81075176ae6dbd6f501e6ea43fd878a29b9c60d term% git/branch front refs/heads/front: 3ca03f92152ed170e12b1ce2416ababbc18ffe54 term% git/branch test refs/heads/test: a81075176ae6dbd6f501e6ea43fd878a29b9c60d term% git/merge front /sys/lib/git/common.rc:88: > can't create: ./A/B/.tmp: './A/B' does not exist The problem is a redirect in `/sys/lib/git/common.rc` that assumes the directory component of the file that contains the diff exists: fn merge1 {@{ rfork e n=$pid out=$1 ours=$2 base=$3 theirs=$4 tmp=$out.tmp while(test -f $tmp){ tmp=$tmp.$n n=`{echo $n + 1 | hoc} } if(! test -f $ours) ours=/dev/null if(! test -f $base) base=/dev/null if(! test -f $theirs) theirs=/dev/null if(! ape/diff3 -3 -m $ours $base $theirs > $tmp) echo merge needed: $out >[1=2] ^^^^^^^^^^^^^^^^ IF THE FOLDER WHERE $tmp LIVES DOES NOT EXIST A REDIRECT TO `> $tmp` FAILS TRIPPING UP THE MERGE if(mergeperm $ours $base $theirs){ mv $tmp $out git/add $out chmod $mergedperms $out } if not { rm -f $tmp $out git/rm $out } }} A solution is to check if the folder exists and create it via `mkdir -p` in case it doesn't. Can someone have a look and confirm this is the right solution and not a hack. If this is Ok plz let me know and I can push the fix. Thanks. Cheers, Igor --- diff 45f713a2bc2961b3c920aed616188591612da210 3c2aa08560fba8a69e09731e3e5d72f7003021e3 --- a/sys/lib/git/common.rc Sun Apr 17 23:25:04 2022 +++ b/sys/lib/git/common.rc Tue Apr 19 13:19:00 2022 @@ -76,7 +76,8 @@ tmp=$tmp.$n n=`{echo $n + 1 | hoc} } - + if(! test -d `{basename -d $tmp}) + mkdir -p `{basename -d $tmp} if(! test -f $ours) ours=/dev/null if(! test -f $base) --upas-evymxpqsmexgrtbayeunvgjskw Content-Disposition: attachment; filename=git.merge.patch Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit From: Igor Böhm Date: Tue, 19 Apr 2022 11:19:00 +0000 Subject: [PATCH] git/merge: fix merge if directory of merged file does not exist When merging from `front` to `test` branch the following test case fails: term% git/init merge.fail.git term% cd merge.fail.git term% mkdir A term% cp /sys/src/cmd/xargs.c A/ term% git/add A/xargs.c term% git/commit -m 'Meh...' A/xargs.c heads/front: 5c36636e55aac3341ce42afee51b73106e8f1bc5 term% git/branch -n test refs/heads/test: 5c36636e55aac3341ce42afee51b73106e8f1bc5 term% mkdir X term% cp /sys/src/cmd/xargs.c X/ term% git/add X/xargs.c term% git/commit -m 'Nein...' X/xargs.c heads/test: 6dc8fecb03f15e1c018c51306d25b10919e8fbe4 term% git/branch front refs/heads/front: 5c36636e55aac3341ce42afee51b73106e8f1bc5 term% mkdir A/B term% cp /sys/src/cmd/xargs.c A/B/ term% git/add A/B/xargs.c term% git/commit -m 'NeinNein...' A/B/xargs.c heads/front: 3ca03f92152ed170e12b1ce2416ababbc18ffe54 term% git/branch test refs/heads/test: 6dc8fecb03f15e1c018c51306d25b10919e8fbe4 term% mkdir X/Y term% cp /sys/src/cmd/xargs.c X/Y/ term% git/add X/Y/xargs.c term% git/commit -m 'NeinNeinNein...' X/Y/xargs.c heads/test: a81075176ae6dbd6f501e6ea43fd878a29b9c60d term% git/branch front refs/heads/front: 3ca03f92152ed170e12b1ce2416ababbc18ffe54 term% git/branch test refs/heads/test: a81075176ae6dbd6f501e6ea43fd878a29b9c60d term% git/merge front /sys/lib/git/common.rc:88: > can't create: ./A/B/.tmp: './A/B' does not exist The problem is a redirect in `/sys/lib/git/common.rc` that assumes the directory component of the file that contains the diff exists: fn merge1 {@{ rfork e n=$pid out=$1 ours=$2 base=$3 theirs=$4 tmp=$out.tmp while(test -f $tmp){ tmp=$tmp.$n n=`{echo $n + 1 | hoc} } if(! test -f $ours) ours=/dev/null if(! test -f $base) base=/dev/null if(! test -f $theirs) theirs=/dev/null if(! ape/diff3 -3 -m $ours $base $theirs > $tmp) echo merge needed: $out >[1=2] ^^^^^^^^^^^^^^^^ IF THE FOLDER WHERE $tmp LIVES DOES NOT EXIST A REDIRECT TO `> $tmp` FAILS TRIPPING UP THE MERGE if(mergeperm $ours $base $theirs){ mv $tmp $out git/add $out chmod $mergedperms $out } if not { rm -f $tmp $out git/rm $out } }} A solution is to check if the folder exists and create it via `mkdir -p` in case it doesn't. --- diff 45f713a2bc2961b3c920aed616188591612da210 3c2aa08560fba8a69e09731e3e5d72f7003021e3 --- a/sys/lib/git/common.rc Sun Apr 17 23:25:04 2022 +++ b/sys/lib/git/common.rc Tue Apr 19 13:19:00 2022 @@ -76,7 +76,8 @@ tmp=$tmp.$n n=`{echo $n + 1 | hoc} } - + if(! test -d `{basename -d $tmp}) + mkdir -p `{basename -d $tmp} if(! test -f $ours) ours=/dev/null if(! test -f $base) --upas-evymxpqsmexgrtbayeunvgjskw--