~ori/git9

793c9c7eea72c35005243cf65b71faf3ad7f9a81 — Ori Bernstein 3 years ago 1b4c50b
common.rc: forgot to commit it.
1 files changed, 31 insertions(+), 17 deletions(-)

M common.rc
M common.rc => common.rc +31 -17
@@ 11,23 11,22 @@ fn usage{
	exit 'usage'
}

# subst [-g] this [that]
fn subst{
	awk 'BEGIN{
		global = 0
		for(i = 1; ARGV[i] ~ /^-/; i++){
			if(ARGV[i] == "-g")
				global = 1
			ARGC--
		}
		this = ARGV[i++]; ARGC--
		that = ARGV[i++]; ARGC--
	}
fn subst {
	awk '
	BEGIN{ARGC=0}
	{sub(ARGV[1], ARGV[2]); print}
	' $*
}

fn drop {
	awk '
	BEGIN{ARGC=0}
	{
		if(global) gsub(this, that)
		else sub(this, that)
		if(index($0, ARGV[1]) == 1)
			$0=substr($0, length(ARGV[1])+1)
		print
	}' $*
	}
	' $*
}

fn present {


@@ 39,7 38,22 @@ fn present {
		status=()
}

# merge1 out theirs base ours
fn whoami{
	name=`{git/conf user.name}
	email=`{git/conf user.email}
	if(test -f /adm/keys.who){
		if(~ $name '')
			name=`{awk -F'|' '$1=="'$user'" {x=$3} END{print x}' </adm/keys.who}
		if(~ $email '')
			email=`{awk -F'|' '$1=="'$user'" {x=$5} END{print x}' </adm/keys.who}
	}
	if(~ $name '')
		name=glenda
	if(~ $email '')
		email=glenda@9front.local
}

# merge1 out ours base theirs
fn merge1 {@{
	rfork e
	n=$pid


@@ 77,7 91,7 @@ fn gitup{
	if(~ $#gitroot 0)
		die 'not a git repository'
	gitfs=$gitroot/.git/fs
	gitrel=`{pwd | subst '^'$"gitroot'/?'}
	gitrel=`{pwd | drop $gitroot | sed 's@^/@@'}
	if(~ $#gitrel 0)
		gitrel='.'
	cd $gitroot