shithub: git9

Download patch

ref: 24836ec6d95204a24a3b4125420cba2dce39cf0d
parent: c2ea4015be2695c2115594e301e725dd9cdb0c32
author: kvik <[email protected]>
date: Wed Apr 8 17:35:52 EDT 2020

Use subst in more places

--- a/branch
+++ b/branch
@@ -53,8 +53,8 @@
 if not
 	base=`{git/query HEAD}
 
-modified=`$nl{git/query -c HEAD $base | grep '^[^-]' | sed 's/^..//'}
-deleted=`$nl{git/query -c HEAD $base | grep '^-' | sed 's/^..//'}
+modified=`$nl{git/query -c HEAD $base | grep '^[^-]' | subst '^..'}
+deleted=`$nl{git/query -c HEAD $base | grep '^-' | subst '^..'}
 
 if(! ~ $#modified 0 || ! ~ $#deleted 0){
 	if(! git/walk -q $modified $deleted){
--- a/clone
+++ b/clone
@@ -6,7 +6,7 @@
 	git/clone remote [local]
 '
 
-remote=`{echo $1 | sed 's@/*$@@g'}
+remote=`{echo $1 | subst -g '/*$'}
 local=$2
 
 if(~ $#remote 0)
@@ -66,7 +66,7 @@
 
 	tree=/mnt/git/HEAD/tree
 	lbranch=`{git/branch}
-	rbranch=`{echo $lbranch | sed 's@^heads@remotes/origin@'}
+	rbranch=`{echo $lbranch | subst '^heads' 'remotes/origin'}
 	echo checking out repository...
 	if(test -f .git/refs/$rbranch){
 		cp .git/refs/$rbranch .git/refs/$lbranch
--- a/commit
+++ b/commit
@@ -45,7 +45,7 @@
 		echo '#'
 		for(p in $parents)
 			echo '# parent:' $p
-		git/walk -fAMR $files | sed 's/^/# /g'
+		git/walk -fAMR $files | subst -g '^' '# '
 		echo '#'
 		echo '# Commit message:'
 	}
--- a/diff
+++ b/diff
@@ -30,7 +30,7 @@
 }
 dirty=`$nl{git/walk -c -fRMA $files}
 if(! ~ $commit HEAD)
-	dirty=($dirty `$nl{git/query -c $commit HEAD | sed 's/^..//'})
+	dirty=($dirty `$nl{git/query -c $commit HEAD | subst '^..'})
 for(f in $dirty){
 	orig=$branch/tree/$f
 	if(! test -f $orig)
--- a/log
+++ b/log
@@ -36,7 +36,7 @@
 	commits=`{git/query $query}
 
 if(! ~ $#* 0)
-	files=`"{walk -f $gitrel/^$* | sed 's@^\./@@' | sort}
+	files=`"{walk -f $gitrel/^$* | subst '^\./' | sort}
 
 while(! ~ $#commits 0){
 	ids=$nids
@@ -43,7 +43,7 @@
 	show=()
 	c=$commits(1)
 	if(! ~ $#files 0){
-		ncomm=`{comm -12 /env/files <{git/query -c $c~ $c | sed 's/^..//' | sort} | wc -l}
+		ncomm=`{comm -12 /env/files <{git/query -c $c~ $c | subst '^..' | sort} | wc -l}
 		if(! ~ $ncomm 0)
 			show=true
 	}
@@ -60,7 +60,7 @@
 			echo -n 'Hash:	'`''{cat $base/$c/hash}
 			echo -n 'Author:	'`''{cat $base/$c/author}
 			echo -n 'Date:	'`''{date `{mtime $base/$c/msg | awk '{print $1}'}}
-			sed 's/^/	/g' $base/$c/msg
+			subst -g '^' '	' <$base/$c/msg 
 			echo
 		}
 	}