git/fs: move mount point to $repo/.git/fs
Moving the mount point to within the repo directory means that we can have multiple git repos mounted at once with no conflict.
This commit is contained in:
parent
1af2546e96
commit
12e952e684
14 changed files with 54 additions and 36 deletions
|
@ -75,14 +75,17 @@ fn gitup{
|
||||||
gitroot=`{git/conf -r >[2]/dev/null}
|
gitroot=`{git/conf -r >[2]/dev/null}
|
||||||
if(~ $#gitroot 0)
|
if(~ $#gitroot 0)
|
||||||
die 'not a git repository'
|
die 'not a git repository'
|
||||||
|
gitfs=$gitroot/.git/fs
|
||||||
gitrel=`{pwd | subst '^'$"gitroot'/?'}
|
gitrel=`{pwd | subst '^'$"gitroot'/?'}
|
||||||
if(~ $#gitrel 0)
|
if(~ $#gitrel 0)
|
||||||
gitrel='.'
|
gitrel='.'
|
||||||
cd $gitroot
|
cd $gitroot
|
||||||
startfs=()
|
startfs=()
|
||||||
if(! test -e /mnt/git/ctl)
|
if(! test -d $gitfs)
|
||||||
|
mkdir -p $gitfs
|
||||||
|
if(! test -e $gitfs/ctl)
|
||||||
startfs=true
|
startfs=true
|
||||||
if(! grep -s '^repo '$gitroot'$' /mnt/git/ctl >[2]/dev/null)
|
if(! grep -s '^repo '$gitroot'$' $gitfs/ctl >[2]/dev/null)
|
||||||
startfs=true
|
startfs=true
|
||||||
if(~ $#startfs 1)
|
if(~ $#startfs 1)
|
||||||
git/fs
|
git/fs
|
||||||
|
|
|
@ -18,7 +18,7 @@ git/pull, git/rm, git/serve
|
||||||
.PP
|
.PP
|
||||||
.B git/branch
|
.B git/branch
|
||||||
[
|
[
|
||||||
.B -adns
|
.B -admns
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
.B -b
|
.B -b
|
||||||
|
@ -211,7 +211,7 @@ This suite of
|
||||||
tools provides a file interface to the
|
tools provides a file interface to the
|
||||||
.I .git
|
.I .git
|
||||||
directory mounted on
|
directory mounted on
|
||||||
.I /mnt/git.
|
.I $repo/.git/fs.
|
||||||
Modifications to the repository are done directly to the
|
Modifications to the repository are done directly to the
|
||||||
.I .git
|
.I .git
|
||||||
directory, and are reflected in the file system interface.
|
directory, and are reflected in the file system interface.
|
||||||
|
@ -304,7 +304,7 @@ flag serves repositories relative to
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
.B Git/fs
|
.B Git/fs
|
||||||
serves a file system on /mnt/git.
|
serves a file system on $repo/.git/fs.
|
||||||
For full documentation, see
|
For full documentation, see
|
||||||
.IR gitfs (4)
|
.IR gitfs (4)
|
||||||
|
|
||||||
|
@ -363,6 +363,13 @@ option, the branch is created but the files are not checked out.
|
||||||
When passed the
|
When passed the
|
||||||
.I -d
|
.I -d
|
||||||
option, the branch is deleted.
|
option, the branch is deleted.
|
||||||
|
.PP
|
||||||
|
When switching branches, git/branch will refuse to clobber
|
||||||
|
modificiations.
|
||||||
|
Passing the
|
||||||
|
.I -m
|
||||||
|
option will cause git9 to attempt to merge the changes between
|
||||||
|
the branches.
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
.B Git/log
|
.B Git/log
|
||||||
|
|
|
@ -20,7 +20,7 @@ Git/fs serves a file system interface to a git repository in the
|
||||||
current directory.
|
current directory.
|
||||||
This file system provides a read-only view into the repository contents.
|
This file system provides a read-only view into the repository contents.
|
||||||
By default, it is mounted on
|
By default, it is mounted on
|
||||||
.B /mnt/git.
|
.B $repo/.git/fs.
|
||||||
It does not cache mutable data, so any changes to the git repository will immediately be reflected in git/fs.
|
It does not cache mutable data, so any changes to the git repository will immediately be reflected in git/fs.
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
|
@ -83,7 +83,7 @@ The git repository being expected.
|
||||||
.B .git/HEAD
|
.B .git/HEAD
|
||||||
A reference to the current HEAD.
|
A reference to the current HEAD.
|
||||||
Used to populate
|
Used to populate
|
||||||
.B /mnt/git/HEAD
|
.B $repo/.git/fs/HEAD
|
||||||
.TP
|
.TP
|
||||||
.git/config
|
.git/config
|
||||||
The per-repository configuation for git tools.
|
The per-repository configuation for git tools.
|
||||||
|
|
|
@ -31,7 +31,7 @@ for(f in $files){
|
||||||
# git/walk doesn't think this came from
|
# git/walk doesn't think this came from
|
||||||
# a checkout.
|
# a checkout.
|
||||||
if(! test -e $addpath)
|
if(! test -e $addpath)
|
||||||
if(~ $add 'tracked' || test -e /mnt/git/HEAD/tree/$f)
|
if(~ $add 'tracked' || test -e $gitfs/HEAD/tree/$f)
|
||||||
touch $addpath
|
touch $addpath
|
||||||
rm -f $delpath
|
rm -f $delpath
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ deleted=()
|
||||||
|
|
||||||
if(~ $#* 0){
|
if(~ $#* 0){
|
||||||
if(~ $#listall 0)
|
if(~ $#listall 0)
|
||||||
awk '$1=="branch"{print $2}' < /mnt/git/ctl
|
awk '$1=="branch"{print $2}' < $gitfs/ctl
|
||||||
if not
|
if not
|
||||||
cd .git/refs/ && walk -f heads remotes
|
cd .git/refs/ && walk -f heads remotes
|
||||||
exit
|
exit
|
||||||
|
@ -95,8 +95,8 @@ for(m in $cleanpaths){
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ours in $dirtypaths){
|
for(ours in $dirtypaths){
|
||||||
common=/mnt/git/object/$orig/tree/$ours
|
common=$gitfs/object/$orig/tree/$ours
|
||||||
theirs=/mnt/git/object/$base/tree/$ours
|
theirs=$gitfs/object/$base/tree/$ours
|
||||||
merge1 $ours $ours $common $theirs
|
merge1 $ours $ours $common $theirs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ if(test -e $local)
|
||||||
fn clone{
|
fn clone{
|
||||||
flag +e
|
flag +e
|
||||||
mkdir -p $local/.git
|
mkdir -p $local/.git
|
||||||
|
mkdir -p $local/.git/fs
|
||||||
mkdir -p $local/.git/objects/pack/
|
mkdir -p $local/.git/objects/pack/
|
||||||
mkdir -p $local/.git/refs/heads/
|
mkdir -p $local/.git/refs/heads/
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ fn clone{
|
||||||
}
|
}
|
||||||
'} |[3] tr '\x0d' '\x0a' || die 'could not clone repository'
|
'} |[3] tr '\x0d' '\x0a' || die 'could not clone repository'
|
||||||
|
|
||||||
tree=/mnt/git/HEAD/tree
|
tree=.git/fs/HEAD/tree
|
||||||
lbranch=`{git/branch}
|
lbranch=`{git/branch}
|
||||||
rbranch=`{echo $lbranch | subst '^heads' 'remotes/origin'}
|
rbranch=`{echo $lbranch | subst '^heads' 'remotes/origin'}
|
||||||
echo checking out repository...
|
echo checking out repository...
|
||||||
|
|
|
@ -19,15 +19,15 @@ fn whoami{
|
||||||
|
|
||||||
fn findbranch{
|
fn findbranch{
|
||||||
branch=`{git/branch}
|
branch=`{git/branch}
|
||||||
if(test -e /mnt/git/branch/$branch/tree){
|
if(test -e $gitfs/branch/$branch/tree){
|
||||||
refpath=.git/refs/$branch
|
refpath=.git/refs/$branch
|
||||||
initial=false
|
initial=false
|
||||||
}
|
}
|
||||||
if not if(test -e /mnt/git/object/$branch/tree){
|
if not if(test -e $gitfs/object/$branch/tree){
|
||||||
refpath=.git/HEAD
|
refpath=.git/HEAD
|
||||||
initial=false
|
initial=false
|
||||||
}
|
}
|
||||||
if not if(! test -e /mnt/git/HEAD/tree){
|
if not if(! test -e $gitfs/HEAD/tree){
|
||||||
refpath=.git/refs/$branch
|
refpath=.git/refs/$branch
|
||||||
initial=true
|
initial=true
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ fn editmsg{
|
||||||
|
|
||||||
fn parents{
|
fn parents{
|
||||||
if(! ~ $#revise 0)
|
if(! ~ $#revise 0)
|
||||||
parents=`{cat /mnt/git/HEAD/parent}
|
parents=`{cat $gitfs/HEAD/parent}
|
||||||
if not if(test -f .git/index9/merge-parents)
|
if not if(test -f .git/index9/merge-parents)
|
||||||
parents=`{cat .git/index9/merge-parents | sort | uniq}
|
parents=`{cat .git/index9/merge-parents | sort | uniq}
|
||||||
if not if(~ $initial true)
|
if not if(~ $initial true)
|
||||||
|
@ -129,8 +129,8 @@ if(~ $#msg 1)
|
||||||
echo $msg >$msgfile.tmp
|
echo $msg >$msgfile.tmp
|
||||||
if not if(~ $#revise 1){
|
if not if(~ $#revise 1){
|
||||||
msg=1
|
msg=1
|
||||||
echo revising commit `{cat /mnt/git/HEAD/hash}
|
echo revising commit `{cat $gitfs/HEAD/hash}
|
||||||
cat /mnt/git/HEAD/msg >$msgfile.tmp
|
cat $gitfs/HEAD/msg >$msgfile.tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
files=()
|
files=()
|
||||||
|
|
|
@ -79,7 +79,7 @@ char *qroot[] = {
|
||||||
|
|
||||||
char gitdir[512];
|
char gitdir[512];
|
||||||
char *username;
|
char *username;
|
||||||
char *mtpt = "/mnt/git";
|
char *mntpt = ".git/fs";
|
||||||
char **branches = nil;
|
char **branches = nil;
|
||||||
Cache uqidcache[512];
|
Cache uqidcache[512];
|
||||||
vlong nextqid = Qmax;
|
vlong nextqid = Qmax;
|
||||||
|
@ -839,8 +839,15 @@ main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
gitinit();
|
gitinit();
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
case 'd': chatty9p++; break;
|
case 'd':
|
||||||
default: usage(); break;
|
chatty9p++;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
mntpt = EARGF(usage());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
}ARGEND;
|
}ARGEND;
|
||||||
if(argc != 0)
|
if(argc != 0)
|
||||||
usage();
|
usage();
|
||||||
|
@ -848,6 +855,6 @@ main(int argc, char **argv)
|
||||||
username = getuser();
|
username = getuser();
|
||||||
branches = emalloc(sizeof(char*));
|
branches = emalloc(sizeof(char*));
|
||||||
branches[0] = nil;
|
branches[0] = nil;
|
||||||
postmountsrv(&gitsrv, nil, "/mnt/git", MCREATE);
|
postmountsrv(&gitsrv, nil, mntpt, MCREATE);
|
||||||
exits(nil);
|
exits(nil);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,9 @@ fn apply @{
|
||||||
msg=''
|
msg=''
|
||||||
parents='-p'^`{git/query HEAD}
|
parents='-p'^`{git/query HEAD}
|
||||||
branch=`{git/branch}
|
branch=`{git/branch}
|
||||||
if(test -e /mnt/git/branch/$branch/tree)
|
if(test -e $gitfs/branch/$branch/tree)
|
||||||
refpath=.git/refs/$branch
|
refpath=.git/refs/$branch
|
||||||
if not if(test -e /mnt/git/object/$branch/tree)
|
if not if(test -e $gitfs/object/$branch/tree)
|
||||||
refpath=.git/HEAD
|
refpath=.git/HEAD
|
||||||
if not
|
if not
|
||||||
die 'invalid branch:' $branch
|
die 'invalid branch:' $branch
|
||||||
|
|
|
@ -3,9 +3,9 @@ rfork ne
|
||||||
. /sys/lib/git/common.rc
|
. /sys/lib/git/common.rc
|
||||||
|
|
||||||
fn merge{
|
fn merge{
|
||||||
ourbr=/mnt/git/object/$1/tree
|
ourbr=$gitfs/object/$1/tree
|
||||||
basebr=/mnt/git/object/$2/tree
|
basebr=$gitfs/object/$2/tree
|
||||||
theirbr=/mnt/git/object/$3/tree
|
theirbr=$gitfs/object/$3/tree
|
||||||
|
|
||||||
all=`$nl{{git/query -c $1 $2; git/query -c $2 $3} | sed 's/^..//' | \
|
all=`$nl{{git/query -c $1 $2; git/query -c $2 $3} | sed 's/^..//' | \
|
||||||
subst -g '^('$ourbr'|'$basebr'|'$theirbr')/*' | sort | uniq}
|
subst -g '^('$ourbr'|'$basebr'|'$theirbr')/*' | sort | uniq}
|
||||||
|
|
|
@ -154,7 +154,7 @@ main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i, j, n;
|
int i, j, n;
|
||||||
Hash *h;
|
Hash *h;
|
||||||
char *p, *e, *s;
|
char *p, *e, *s, *objpfx;
|
||||||
char query[2048], repo[512];
|
char query[2048], repo[512];
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
|
@ -173,6 +173,8 @@ main(int argc, char **argv)
|
||||||
sysfatal("find root: %r");
|
sysfatal("find root: %r");
|
||||||
if(chdir(repo) == -1)
|
if(chdir(repo) == -1)
|
||||||
sysfatal("chdir: %r");
|
sysfatal("chdir: %r");
|
||||||
|
if((objpfx = smprint("%s/.git/fs/object/", repo)) == nil)
|
||||||
|
sysfatal("smprint: %r");
|
||||||
s = "";
|
s = "";
|
||||||
p = query;
|
p = query;
|
||||||
e = query + nelem(query);
|
e = query + nelem(query);
|
||||||
|
@ -187,7 +189,7 @@ main(int argc, char **argv)
|
||||||
sysfatal("diff: need 2 commits, got %d", n);
|
sysfatal("diff: need 2 commits, got %d", n);
|
||||||
diffcommits(h[0], h[1]);
|
diffcommits(h[0], h[1]);
|
||||||
}else{
|
}else{
|
||||||
p = (fullpath ? "/mnt/git/object/" : "");
|
p = (fullpath ? objpfx : "");
|
||||||
for(j = 0; j < n; j++)
|
for(j = 0; j < n; j++)
|
||||||
print("%s%H\n", p, h[reverse ? n - 1 - j : j]);
|
print("%s%H\n", p, h[reverse ? n - 1 - j : j]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ while(! ~ $#todo 0){
|
||||||
exit
|
exit
|
||||||
case s squash
|
case s squash
|
||||||
git/export $c | git/import -n
|
git/export $c | git/import -n
|
||||||
msg=`''{cat /mnt/git/HEAD/msg; echo; cat /mnt/git/object/$c/msg}
|
msg=`''{cat $gitfs/HEAD/msg; echo; cat $gitfs/object/$c/msg}
|
||||||
git/commit -rem $msg .
|
git/commit -rem $msg .
|
||||||
case f fixup
|
case f fixup
|
||||||
git/export $c | git/import -n
|
git/export $c | git/import -n
|
||||||
|
|
|
@ -7,7 +7,7 @@ gitup
|
||||||
flagfmt='c:query query' args='file ...'
|
flagfmt='c:query query' args='file ...'
|
||||||
eval `''{aux/getflags $*} || exec aux/usage
|
eval `''{aux/getflags $*} || exec aux/usage
|
||||||
|
|
||||||
commit=/mnt/git/HEAD
|
commit=$gitfs/HEAD
|
||||||
if(~ $#query 1)
|
if(~ $#query 1)
|
||||||
commit=`{git/query -p $query}
|
commit=`{git/query -p $query}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#define NCACHE 4096
|
#define NCACHE 4096
|
||||||
#define TDIR ".git/index9/tracked"
|
#define TDIR ".git/index9/tracked"
|
||||||
#define RDIR ".git/index9/removed"
|
#define RDIR ".git/index9/removed"
|
||||||
#define HDIR "/mnt/git/HEAD/tree"
|
#define HDIR ".git/fs/HEAD/tree"
|
||||||
typedef struct Cache Cache;
|
typedef struct Cache Cache;
|
||||||
typedef struct Wres Wres;
|
typedef struct Wres Wres;
|
||||||
struct Cache {
|
struct Cache {
|
||||||
|
@ -246,16 +246,14 @@ main(int argc, char **argv)
|
||||||
usage();
|
usage();
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
||||||
if(access("/mnt/git/ctl", AEXIST) != 0)
|
|
||||||
sysfatal("no running git/fs");
|
|
||||||
if(findrepo(repo, sizeof(repo)) == -1)
|
if(findrepo(repo, sizeof(repo)) == -1)
|
||||||
sysfatal("find root: %r");
|
sysfatal("find root: %r");
|
||||||
if(chdir(repo) == -1)
|
if(chdir(repo) == -1)
|
||||||
sysfatal("chdir: %r");
|
sysfatal("chdir: %r");
|
||||||
|
if(access(".git/fs/ctl", AEXIST) != 0)
|
||||||
|
sysfatal("no running git/fs");
|
||||||
dirty = 0;
|
dirty = 0;
|
||||||
memset(&r, 0, sizeof(r));
|
memset(&r, 0, sizeof(r));
|
||||||
if(access("/mnt/git/ctl", AEXIST) != 0)
|
|
||||||
sysfatal("git/fs does not seem to be running");
|
|
||||||
if(printflg == 0)
|
if(printflg == 0)
|
||||||
printflg = Tflg | Aflg | Mflg | Rflg;
|
printflg = Tflg | Aflg | Mflg | Rflg;
|
||||||
if(argc == 0){
|
if(argc == 0){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue