Skip to content

Commit

Permalink
all: sync with 9front
Browse files Browse the repository at this point in the history
  • Loading branch information
oridb committed Jun 30, 2021
1 parent 30f2516 commit c65ded4
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 56 deletions.
4 changes: 1 addition & 3 deletions add
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ for(f in $files){
# We don't want a matching qid, so that
# git/walk doesn't think this came from
# a checkout.
if(! test -e $addpath)
if(~ $add 'tracked' || test -e $gitfs/HEAD/tree/$f)
touch $addpath
echo -n > $addpath
rm -f $delpath
}
}
Expand Down
23 changes: 13 additions & 10 deletions branch
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ if not if(test -e .git/$new)
if not
base=`{git/query HEAD}
if(~ $#newbr 0){
if(! ~ $#baseref 0)
die update would clobber $branch with $baseref
baseref=`$nl{echo -n $new | sed s@refs/heads/@refs/remotes/origin/@}
echo $baseref
if(! test -e .git/$new)
if(! base=`{git/query $baseref})
die could not find branch $branch
}
modified=`$nl{git/query -c HEAD $base | grep '^[^-]' | subst '^..'}
deleted=`$nl{git/query -c HEAD $base | grep '^-' | subst '^..'}
Expand All @@ -49,14 +58,6 @@ if(~ $delete 1){
echo 'deleted branch' $new
exit
}
if(~ $#newbr 0){
if(! ~ $#baseref 0)
die update would clobber $branch with $baseref
baseref=`$nl{echo -n $new | sed s@refs/heads/@refs/remotes/origin/@}
if(! test -e .git/$new)
if(! base=`{git/query $baseref})
die could not find branch $branch
}
commit=`{git/query $base} || die 'branch does not exist:' $base
if(~ $new */*)
mkdir -p .git/`{basename -d $new}
Expand Down Expand Up @@ -99,8 +100,10 @@ for(m in $cleanpaths){
rm -rf .git/index9/tracked/$m
}
if(~ $b file){
cp $basedir/tree/$m $m
walk -eq $m > .git/index9/tracked/$m
if(cp -x -- $basedir/tree/$m $m)
walk -eq $m > .git/index9/tracked/$m
if not
echo -n > .git/index9/tracked/$m
}
}
Expand Down
Empty file modified commit
100755 → 100644
Empty file.
1 change: 1 addition & 0 deletions conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ main(int argc, char **argv)
file[nfile++] = ".git/config";
if((p = getenv("home")) != nil)
file[nfile++] = smprint("%s/lib/git/config", p);
file[nfile++] = "/sys/lib/git/config";
}

for(i = 0; i < argc; i++){
Expand Down
Empty file modified diff
100755 → 100644
Empty file.
7 changes: 1 addition & 6 deletions fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,8 @@ fetchpack(Conn *c, int pfd, char *packtmp)
req = 1;
}
flushpkt(c);
if(resolveref(&h, "HEAD") != -1){
n = snprint(buf, sizeof(buf), "have %H\n", h);
if(writepkt(c, buf, n + 1) == -1)
sysfatal("could not send have for %H", have[i]);
}
for(i = 0; i < nref; i++){
if(hasheq(&have[i], &Zhash) || hasheq(&have[i], &h))
if(hasheq(&have[i], &Zhash))
continue;
n = snprint(buf, sizeof(buf), "have %H\n", have[i]);
if(writepkt(c, buf, n + 1) == -1)
Expand Down
25 changes: 16 additions & 9 deletions fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ char *qroot[] = {

char gitdir[512];
char *username;
char *groupname;
char *mntpt = ".git/fs";
char **branches = nil;
Cache uqidcache[512];
Expand Down Expand Up @@ -164,7 +165,7 @@ obj2dir(Dir *d, Crumb *c, Object *o, char *name)
d->mode = c->mode;
d->name = estrdup9p(name);
d->uid = estrdup9p(username);
d->gid = estrdup9p(username);
d->gid = estrdup9p(groupname);
d->muid = estrdup9p(username);
if(o->type == GBlob || o->type == GTag){
d->qid.type = 0;
Expand All @@ -188,7 +189,7 @@ rootgen(int i, Dir *d, void *p)
d->qid.type = strcmp(qroot[i], "ctl") == 0 ? 0 : QTDIR;
d->qid.path = qpath(nil, i, i, Qroot);
d->uid = estrdup9p(username);
d->gid = estrdup9p(username);
d->gid = estrdup9p(groupname);
d->muid = estrdup9p(username);
d->mtime = c->mtime;
return 0;
Expand All @@ -210,7 +211,7 @@ branchgen(int i, Dir *d, void *p)
d->qid.path = qpath(c, i, branchid(aux, aux->refpath), Qbranch | Internal);
d->mode = 0555 | DMDIR;
d->uid = estrdup9p(username);
d->gid = estrdup9p(username);
d->gid = estrdup9p(groupname);
d->muid = estrdup9p(username);
d->mtime = c->mtime;
d->atime = c->mtime;
Expand Down Expand Up @@ -251,11 +252,10 @@ gtreegen(int i, Dir *d, void *p)
d->qid.type = o->type == GTree ? QTDIR : 0;
d->qid.path = qpath(c, i, o->id, aux->qdir);
d->mode = m;
d->mode |= (o->type == GTree) ? 0755 : 0644;
d->atime = c->mtime;
d->mtime = c->mtime;
d->uid = estrdup9p(username);
d->gid = estrdup9p(username);
d->gid = estrdup9p(groupname);
d->muid = estrdup9p(username);
d->name = estrdup9p(e->tree->ent[i].name);
d->length = o->size;
Expand All @@ -271,7 +271,7 @@ gcommitgen(int i, Dir *d, void *p)
c = crumb(p, 0);
o = c->obj;
d->uid = estrdup9p(username);
d->gid = estrdup9p(username);
d->gid = estrdup9p(groupname);
d->muid = estrdup9p(username);
d->mode = 0444;
d->atime = o->commit->ctime;
Expand Down Expand Up @@ -490,7 +490,7 @@ objwalk1(Qid *q, Object *o, Crumb *p, Crumb *c, char *name, vlong qdir, Gitaux *
}else if(o->type == GCommit){
q->type = 0;
c->mtime = o->commit->mtime;
c->mode = 0444;
c->mode = 0644;
assert(qdir == Qcommit || qdir == Qobject || qdir == Qcommittree || qdir == Qhead);
if(strcmp(name, "msg") == 0)
q->path = qpath(p, 0, o->id, Qcommitmsg);
Expand Down Expand Up @@ -804,7 +804,7 @@ gitstat(Req *r)
aux = r->fid->aux;
c = crumb(aux, 0);
r->d.uid = estrdup9p(username);
r->d.gid = estrdup9p(username);
r->d.gid = estrdup9p(groupname);
r->d.muid = estrdup9p(username);
r->d.qid = r->fid->qid;
r->d.mtime = c->mtime;
Expand Down Expand Up @@ -837,6 +837,8 @@ usage(void)
void
main(int argc, char **argv)
{
Dir *d;

gitinit();
ARGBEGIN{
case 'd':
Expand All @@ -852,7 +854,12 @@ main(int argc, char **argv)
if(argc != 0)
usage();

username = getuser();
if((d = dirstat(".git")) == nil)
sysfatal("dirstat .git: %r");
username = strdup(d->uid);
groupname = strdup(d->gid);
free(d);

branches = emalloc(sizeof(char*));
branches[0] = nil;
postmountsrv(&gitsrv, nil, mntpt, MCREATE);
Expand Down
14 changes: 11 additions & 3 deletions import
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn apply @{
date=$0
}
state=="headers" && /^Subject:/{
sub(/^Subject:[ \t]*(\[PATCH( [0-9]+\/[0-9]+)?\])*[ \t]*/, "", $0);
sub(/^Subject:[ \t]*(\[[^\]]*\][ \t]*)*/, "", $0);
gotmsg = 1
print > "/env/msg"
}
Expand Down Expand Up @@ -94,6 +94,14 @@ eval `''{aux/getflags $*} || exec aux/usage
patches=(/fd/0)
if(! ~ $#* 0)
patches=$*
for(f in $patches)
apply < $f || die $status
for(p in $patches){
# upas serves the decoded header and body separately,
# so we cat them together when applying a upas message.
#
# this allows mime-encoded or line-wrapped patches.
if(test -d $p && test -f $p/header && test -f $p/body)
{{cat $p/header; echo; cat $p/body} | apply} || die $status
if not
apply < $p || die $status
}
exit ''
49 changes: 49 additions & 0 deletions log
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/rc -e
rfork en
. /sys/lib/git/common.rc

gitup

flagfmt='e:expr expression, c:branch commit, s:short'; args='file ...'
eval `''{aux/getflags $*} || exec aux/usage
base=/mnt/git/object/
if(~ $#branch 0)
branch=`{git/branch}
if(~ $#expr 0)
commits=`{git/query $branch}
if not
commits=`{git/query $expr}
files=()
if(! ~ $#* 0)
files=`"{walk -f $gitrel/^$* | subst '^\./' | sort}
while(! ~ $#commits 0){
ids=$nids
show=()
c=$commits(1)
if(! ~ $#files 0){
ncomm=`{comm -12 /env/files <{git/query -c $c~ $c | subst '^..' | sort} | wc -l}
if(! ~ $ncomm 0)
show=true
}
commits=$commits(2-)
if(~ $#expr 0)
commits=($commits `{cat $base/$c/parent >[2]/dev/null})
if(! ~ $#commits 0)
commits=`$nl{walk -emp -n0 $base^$commits | sort -rn | uniq | awk -F/ '{print $NF}'}
if(~ $#files 0 || ~ $show true){
if(~ $short 1)
echo $c `{cat $base/$c/msg | sed 1q}
if not{
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}'}}
subst -g '^' ' ' <$base/$c/msg
echo
}
}
}
exit ''
16 changes: 11 additions & 5 deletions log.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void
main(int argc, char **argv)
{
char path[1024], repo[1024], *p, *r;
int i;
int i, nrepo;

ARGBEGIN{
case 'e':
Expand All @@ -301,15 +301,21 @@ main(int argc, char **argv)

if(findrepo(repo, sizeof(repo)) == -1)
sysfatal("find root: %r");
nrepo = strlen(repo);
if(argc != 0){
if(getwd(path, sizeof(path)) == nil)
sysfatal("getwd: %r");
if(strlen(path) < strlen(repo))
sysfatal("path changed");
p = path + strlen(repo);
if(strncmp(path, repo, nrepo) != 0)
sysfatal("path shifted??");
p = path + nrepo;
pathfilt = emalloc(sizeof(Pfilt));
for(i = 0; i < argc; i++){
r = smprint("./%s/%s", p, argv[i]);
if(*argv[i] == '/'){
if(strncmp(argv[i], repo, nrepo) != 0)
continue;
r = smprint("./%s", argv[i]+nrepo);
}else
r = smprint("./%s/%s", p, argv[i]);
cleanname(r);
filteradd(pathfilt, r);
free(r);
Expand Down
Loading

0 comments on commit c65ded4

Please sign in to comment.