2021-05-17 20:46:44 +00:00
|
|
|
nl='
|
|
|
|
'
|
|
|
|
|
|
|
|
fn die{
|
|
|
|
>[1=2] echo $0: $*
|
|
|
|
exit $"*
|
|
|
|
}
|
|
|
|
|
|
|
|
fn usage{
|
|
|
|
>[1=2] echo -n 'usage:' $usage
|
|
|
|
exit 'usage'
|
|
|
|
}
|
|
|
|
|
2021-08-17 04:31:15 +00:00
|
|
|
fn subst {
|
|
|
|
awk '
|
|
|
|
BEGIN{ARGC=0}
|
|
|
|
{sub(ARGV[1], ARGV[2]); print}
|
|
|
|
' $*
|
|
|
|
}
|
|
|
|
|
|
|
|
fn drop {
|
|
|
|
awk '
|
|
|
|
BEGIN{ARGC=0}
|
2021-05-17 20:46:44 +00:00
|
|
|
{
|
2021-08-17 04:31:15 +00:00
|
|
|
if(index($0, ARGV[1]) == 1)
|
|
|
|
$0=substr($0, length(ARGV[1])+1)
|
2021-05-17 20:46:44 +00:00
|
|
|
print
|
2021-08-17 04:31:15 +00:00
|
|
|
}
|
|
|
|
' $*
|
2021-05-17 20:46:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn present {
|
|
|
|
if(~ $1 /dev/null && cmp $2 $3>/dev/null)
|
|
|
|
status=gone
|
|
|
|
if not if (~ $3 /dev/null && cmp $1 $2>/dev/null)
|
|
|
|
status=gone
|
|
|
|
if not
|
|
|
|
status=()
|
|
|
|
}
|
|
|
|
|
|
|
|
# merge1 out theirs base ours
|
2021-06-05 17:42:05 +00:00
|
|
|
fn merge1 {@{
|
|
|
|
rfork e
|
2021-05-17 20:46:44 +00:00
|
|
|
n=$pid
|
|
|
|
out=$1
|
2021-06-05 18:50:20 +00:00
|
|
|
ours=$2
|
2021-05-17 20:46:44 +00:00
|
|
|
base=$3
|
2021-06-05 18:50:20 +00:00
|
|
|
theirs=$4
|
2021-05-17 20:46:44 +00:00
|
|
|
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)
|
2021-06-05 17:42:05 +00:00
|
|
|
echo merge needed: $out >[1=2]
|
2021-05-17 20:46:44 +00:00
|
|
|
|
|
|
|
if(present $ours $base $theirs){
|
|
|
|
mv $tmp $out
|
|
|
|
git/add $out
|
|
|
|
}
|
|
|
|
if not {
|
|
|
|
rm -f $tmp $out
|
|
|
|
git/rm $out
|
|
|
|
}
|
2021-06-05 18:50:20 +00:00
|
|
|
}}
|
2021-05-17 20:46:44 +00:00
|
|
|
|
|
|
|
fn gitup{
|
|
|
|
gitroot=`{git/conf -r >[2]/dev/null}
|
|
|
|
if(~ $#gitroot 0)
|
|
|
|
die 'not a git repository'
|
2021-05-31 00:46:21 +00:00
|
|
|
gitfs=$gitroot/.git/fs
|
2021-08-17 04:31:15 +00:00
|
|
|
gitrel=`{pwd | drop $gitroot | sed 's@^/@@'}
|
2021-05-17 20:46:44 +00:00
|
|
|
if(~ $#gitrel 0)
|
|
|
|
gitrel='.'
|
|
|
|
cd $gitroot
|
|
|
|
startfs=()
|
2021-05-31 00:46:21 +00:00
|
|
|
if(! test -d $gitfs)
|
|
|
|
mkdir -p $gitfs
|
|
|
|
if(! test -e $gitfs/ctl)
|
2021-05-17 20:46:44 +00:00
|
|
|
startfs=true
|
2021-05-31 00:46:21 +00:00
|
|
|
if(! grep -s '^repo '$gitroot'$' $gitfs/ctl >[2]/dev/null)
|
2021-05-17 20:46:44 +00:00
|
|
|
startfs=true
|
|
|
|
if(~ $#startfs 1)
|
|
|
|
git/fs
|
|
|
|
if not
|
|
|
|
status=''
|
|
|
|
}
|