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)