git/compat: expand to cover go bootstrap
go bootstrap uses more of git than we supported, so stub in enough that we can bootstrap go.
This commit is contained in:
parent
21aac62c1f
commit
126cc163e2
1 changed files with 62 additions and 3 deletions
65
sys/src/cmd/git/compat
Executable file → Normal file
65
sys/src/cmd/git/compat
Executable file → Normal file
|
@ -94,7 +94,7 @@ fn cmd_rev-parse{
|
||||||
echo `{dcmd git9/branch | sed s@^heads/@@g}
|
echo `{dcmd git9/branch | sed s@^heads/@@g}
|
||||||
shift
|
shift
|
||||||
case *
|
case *
|
||||||
dprint option $opt
|
die unknown option $opt
|
||||||
}
|
}
|
||||||
shift
|
shift
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,15 @@ fn cmd_show-ref{
|
||||||
echo `{cat $gitroot/.git/refs/$b} refs/$b
|
echo `{cat $gitroot/.git/refs/$b} refs/$b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cmd_rev-parse{
|
||||||
|
switch($1){
|
||||||
|
case --git-dir
|
||||||
|
echo `{git/conf -r}^/.git
|
||||||
|
case *
|
||||||
|
die 'unknown rev-parse '$*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn cmd_remote{
|
fn cmd_remote{
|
||||||
if({! ~ $#* 3 && ! ~ $#* 4} || ! ~ $1 add)
|
if({! ~ $#* 3 && ! ~ $#* 4} || ! ~ $1 add)
|
||||||
die unimplemented remote cmd $*
|
die unimplemented remote cmd $*
|
||||||
|
@ -125,6 +134,44 @@ fn cmd_remote{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cmd_log{
|
||||||
|
count=()
|
||||||
|
format=''
|
||||||
|
while(~ $1 -*){
|
||||||
|
switch($1){
|
||||||
|
case --format
|
||||||
|
format=$2
|
||||||
|
shift
|
||||||
|
case '--format='*
|
||||||
|
format=`{echo $1 | sed 's/--format=//g'}
|
||||||
|
case -n
|
||||||
|
count=-n$2
|
||||||
|
shift
|
||||||
|
case -n*
|
||||||
|
count=$1
|
||||||
|
case *
|
||||||
|
dprint option $opt
|
||||||
|
}
|
||||||
|
shift
|
||||||
|
}
|
||||||
|
@{cd $gitroot && git/fs}
|
||||||
|
switch($format){
|
||||||
|
case ''
|
||||||
|
git/log $count
|
||||||
|
case '%H:%ct'
|
||||||
|
for(c in `{git/log -s $count| awk '{print $1}'})
|
||||||
|
echo $c:`{mtime $gitroot/.git/fs/object/$c/msg}
|
||||||
|
case '%h %cd'
|
||||||
|
for(c in `{git/log -s $count| awk '{print $1}'})
|
||||||
|
echo $c `{date `{mtime $gitroot/.git/fs/object/$c/msg}}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cmd_show{
|
||||||
|
cmd_log -n1 $*
|
||||||
|
}
|
||||||
|
|
||||||
fn cmd_ls-remote{
|
fn cmd_ls-remote{
|
||||||
if(~ $1 -q)
|
if(~ $1 -q)
|
||||||
shift
|
shift
|
||||||
|
@ -138,6 +185,9 @@ fn cmd_version{
|
||||||
echo git version 2.2.0
|
echo git version 2.2.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cmd_status{
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
fn usage{
|
fn usage{
|
||||||
echo 'git <command> <args>' >[1=2]
|
echo 'git <command> <args>' >[1=2]
|
||||||
|
@ -158,11 +208,20 @@ if(~ $0 *compat){
|
||||||
exec rc
|
exec rc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(~ $#gitcompatdebug 1)
|
||||||
|
echo running $* >>/tmp/gitlog
|
||||||
|
|
||||||
|
if(~ $1 -c)
|
||||||
|
shift 2
|
||||||
|
if(~ $1 -c*)
|
||||||
|
shift 1
|
||||||
if(! test -f '/env/fn#cmd_'$1)
|
if(! test -f '/env/fn#cmd_'$1)
|
||||||
die git $1: commmand not implemented
|
die git $1: commmand not implemented
|
||||||
if(! ~ $1 init && ! ~ $1 clone)
|
if(! ~ $1 init && ! ~ $1 clone)
|
||||||
gitroot=`{git/conf -r} || die repo
|
gitroot=`{git/conf -r} || die repo
|
||||||
|
|
||||||
echo $* >/tmp/gitlog
|
if(~ $#gitcompatdebug 1)
|
||||||
cmd_$1 $*(2-)
|
cmd_$1 $*(2-) | tee >>/tmp/gitlog
|
||||||
|
if not
|
||||||
|
cmd_$1 $*(2-)
|
||||||
exit ''
|
exit ''
|
||||||
|
|
Loading…
Reference in a new issue