summaryrefslogtreecommitdiff
path: root/sys/src/cmd/git
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2022-07-03 04:25:08 +0000
committerOri Bernstein <ori@eigenstate.org>2022-07-03 04:25:08 +0000
commit126cc163e20e0dca5851151d901f6d9eac5745b9 (patch)
treed45dde26840ad3bb50e3575a44bf551abce86b6f /sys/src/cmd/git
parent21aac62c1f0fa565a860d4880ec56b84eb9dd8dd (diff)
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.
Diffstat (limited to 'sys/src/cmd/git')
-rw-r--r--[-rwxr-xr-x]sys/src/cmd/git/compat65
1 files changed, 62 insertions, 3 deletions
diff --git a/sys/src/cmd/git/compat b/sys/src/cmd/git/compat
index 25d14308f..f61ff71e9 100755..100644
--- a/sys/src/cmd/git/compat
+++ b/sys/src/cmd/git/compat
@@ -94,7 +94,7 @@ fn cmd_rev-parse{
echo `{dcmd git9/branch | sed s@^heads/@@g}
shift
case *
- dprint option $opt
+ die unknown option $opt
}
shift
}
@@ -112,6 +112,15 @@ fn cmd_show-ref{
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{
if({! ~ $#* 3 && ! ~ $#* 4} || ! ~ $1 add)
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{
if(~ $1 -q)
shift
@@ -138,6 +185,9 @@ fn cmd_version{
echo git version 2.2.0
}
+fn cmd_status{
+ echo
+}
fn usage{
echo 'git <command> <args>' >[1=2]
@@ -158,11 +208,20 @@ if(~ $0 *compat){
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)
die git $1: commmand not implemented
if(! ~ $1 init && ! ~ $1 clone)
gitroot=`{git/conf -r} || die repo
-echo $* >/tmp/gitlog
-cmd_$1 $*(2-)
+if(~ $#gitcompatdebug 1)
+ cmd_$1 $*(2-) | tee >>/tmp/gitlog
+if not
+ cmd_$1 $*(2-)
exit ''