[9fans] Git/fs: Possibly Usable

2019-04-01 Thread ori
It was mentioned on this list a short while ago. Now, it's
more or less at the point where it works for me. Expect
many bugs and problems, and many more missing tools, but
"the rest is just scripting".

One caveat I have: Git's index file format is a bit
boneheaded, so I'm ignoring it. The index doesn't affect
the wire protocol, so this isn't an interoperability issue,
unless you share the same physical repository on both
Plan 9 and Unix. If you do, expect them to get out of
sync on uncommitted but added files.

In fact, the entire concept of the staging area has been
removed, as it's both confusing and clunky. There are now
only three states that files can be in: 'untracked',
'dirty', and 'committed'. Tracking is done with empty
files under .git/index9/{removed,tracked}/path/to/file.

It's implemented in Plan 9 flavor C, and provides tools
for writing repository contents, and a file system for
read-only access, which will mirror the current state of
the repository.

The code is here: https://bitbucket.org/oridb/git9

Install with `mk install`. There's no recursive binding
of directories, so you need to union /rc/bin/git and
$objtype/bin/git` by hand.

Documentation has not yet been written. You'll need to
read the source.

Some usage examples:

git/clone git://git.eigenstate.org/git/ori/mc.git
git/log
cd subdir/name
git/add foo.c
git/commit
git/push

Scripts will generally mount git/fs as needed to do
their work, but if you want to browse the repository
manually, run it yourself. You'll get `/n/git` mounted,
with the following contents:

/n/git/object:  The objects in the repo.
/n/git/branch:  The branches in the repo.
/n/git/ctl: A file showing the status of the repo.
Currently, it only shows the current 
branch.

Commits are presented as directories with the following
contents:

author: A file containing the author name
hash:   A file containing the commit hash
parent: A file containing the commit parents, one per line.
msg:A file containing the log message for that commit
tree:   A directory containing a view of the repository.

So, for example:

% ls /n/git/branch/heads/master
/n/git/branch/heads/master/author
/n/git/branch/heads/master/hash
/n/git/branch/heads/master/msg
/n/git/branch/heads/master/parent
/n/git/branch/heads/master/tree
% cat /n/git/branch/heads/master/hash
7d539a7c08aba3f31b3913e0efef11c43ea9

# This is the same commit, with the same contents.
% ls /n/git/object/7d539a7c08aba3f31b3913e0efef11c43ea9f9ef
/n/git/object/7d539a7c08aba3f31b3913e0efef11c43ea9f9ef/author
/n/git/object/7d539a7c08aba3f31b3913e0efef11c43ea9f9ef/hash
/n/git/object/7d539a7c08aba3f31b3913e0efef11c43ea9f9ef/msg
/n/git/object/7d539a7c08aba3f31b3913e0efef11c43ea9f9ef/parent
/n/git/object/7d539a7c08aba3f31b3913e0efef11c43ea9f9ef/tree

# what git/diff will hopefully do more concisely soon, filtering
# out the non-git files.
ape/diff -ur /n/git/branch/heads/master/tree .
Only in .: .git
Only in .: debug
diff -ur /n/git/branch/heads/master/tree/fold.myr ./fold.myr
--- /n/git/branch/heads/master/tree/fold.myrWed Dec 31 16:00:00 1969
+++ ./fold.myr  Mon Apr  1 21:39:06 2019
@@ -6,6 +6,8 @@
const foldexpr : (e : expr# -> std.option(constval))
 ;;
 
+/* Look, diffing files just works, and I don't need any fancy glue! */
+
 const foldexpr = {e
match e
| &(`Eident &[.sc=`Sclassenum, .name=name, .ty=`Tyenum &(`Body 
enum)]):
Only in .: refs


The following utilities and binaries are provided:

fs: The git filesystem.
fetch:  The protocol bits for getting data from a git server.
send:   The protocol bits for sending data to a git server.
save:   The gnarly bits for storing the files for a commit.
conf:   A program to extract information from a config file.
clone:  Clones a repository.
commit: Commits a snapshot of the working directory.
log:Prints the contents of a commmit log.
add:Tells the repository to add a file to the next commit.
walk:   `du`, but for git status.


Supported protocols: git:// and git+ssh://. If someone
implements others, I'll gladly accept patches.

TODOs:
git/mkpatch:Generate a 'git am' compatible patch.
git/apply:  Apply a diff.
git/diff:   Wrapper wrapper around git/walk that
diffs the changed files.
git/merge:  Yup, what it says on the label. Should
also be a script around git/fs.
git/log:Need to figure out how to make it filter
  

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct?

2019-04-01 Thread Skip Tavakkolian
what I have in /sys/src/cmd/cc here is identical to what's on 9p.io.

On Mon, Apr 1, 2019 at 7:23 PM Kurt H Maier  wrote:

> On Mon, Apr 01, 2019 at 09:20:43PM -0400, Dan Cross wrote:
> > On Mon, Apr 1, 2019 at 8:36 PM Kurt H Maier  wrote:
> >
> > > On Mon, Apr 01, 2019 at 08:26:30PM -0400, Jeremy O'Brien wrote:
> > > > On Mon, Apr 1, 2019, at 11:33, Kyohei Kadota wrote:
> > > > > Hi, 9fans. I use 9legacy.
> > > > >
> > > > > About below program, I expected that flags field will initialize to
> > > > > zero but the value of flags was a garbage, ex, "f8f7".
> > > > > Is this expected?
> > > > >
> > > > > ```
> > > > > #include 
> > > > >
> > > > > struct option {
> > > > > int n;
> > > > > char *s;
> > > > > int flags;
> > > > > };
> > > > >
> > > > > int
> > > > > main(void)
> > > > > {
> > > > > struct option opt = {1, "test"};
> > > > > printf("%d %s %x\n", opt.n, opt.s, opt.flags);
> > > > > return 0;
> > > > > }
> > > > > ```
> > > > >
> > > > >
> > > >
> > > > According to C99: "If an object that has automatic storage duration
> is
> > > not initialized explicitly, its value is indeterminate."
> > > >
> > > > Stack variable == automatic storage duration. This appears to be
> correct
> > > behavior to me.
> > > >
> > >
> > > Can anyone provide the patches 9legacy uses to implement C99
> compliance?
> >
> >
> > There were actually quite a few of them, mostly done by Geoff Collyer.
> The
> > compiler sources list contains a list of desiderata in a file called
> `c99`;
> > of course, the plan9 compilers aren't completely compliant (they weren't
> > trying to be). Incidentally this file has been carried forward into, for
> > example, /sys/src/cmd/cc/c99 in the 9front distribution (and other plan9
> > derivatives).
> >
> > In the present case, this appears to be a compiler bug. The
> aforementioned
> > reference to n1548 sec 6.7.9 para 10 is incorrect in that there _is_ an
> > explicit initializer here. The relevant text in the standard is sec 6.7.9
> > pp 16-21, which specifies that in the event that an explicit initializer
> > does not completely cover (in a topological sense) the thing it is
> > initializing, then the elements not covered shall be initialized as if
> they
> > had _static_ storage duration; that is, they should be zeroed.
> >
> > Now as I said, the Plan 9 C compilers aren't explicit C99 compliant. But
> > given that the `c99` file describes things related to initializer lists
> as
> > being unneeded because they were already implemented, one may assume it
> was
> > believed that this was covered by c99 behavior. It isn't.
> >
> > - Dan C.
>
> So, no?
>
> khm
>
>


Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct?

2019-04-01 Thread Kurt H Maier
On Mon, Apr 01, 2019 at 09:20:43PM -0400, Dan Cross wrote:
> On Mon, Apr 1, 2019 at 8:36 PM Kurt H Maier  wrote:
> 
> > On Mon, Apr 01, 2019 at 08:26:30PM -0400, Jeremy O'Brien wrote:
> > > On Mon, Apr 1, 2019, at 11:33, Kyohei Kadota wrote:
> > > > Hi, 9fans. I use 9legacy.
> > > >
> > > > About below program, I expected that flags field will initialize to
> > > > zero but the value of flags was a garbage, ex, "f8f7".
> > > > Is this expected?
> > > >
> > > > ```
> > > > #include 
> > > >
> > > > struct option {
> > > > int n;
> > > > char *s;
> > > > int flags;
> > > > };
> > > >
> > > > int
> > > > main(void)
> > > > {
> > > > struct option opt = {1, "test"};
> > > > printf("%d %s %x\n", opt.n, opt.s, opt.flags);
> > > > return 0;
> > > > }
> > > > ```
> > > >
> > > >
> > >
> > > According to C99: "If an object that has automatic storage duration is
> > not initialized explicitly, its value is indeterminate."
> > >
> > > Stack variable == automatic storage duration. This appears to be correct
> > behavior to me.
> > >
> >
> > Can anyone provide the patches 9legacy uses to implement C99 compliance?
> 
> 
> There were actually quite a few of them, mostly done by Geoff Collyer.  The
> compiler sources list contains a list of desiderata in a file called `c99`;
> of course, the plan9 compilers aren't completely compliant (they weren't
> trying to be). Incidentally this file has been carried forward into, for
> example, /sys/src/cmd/cc/c99 in the 9front distribution (and other plan9
> derivatives).
> 
> In the present case, this appears to be a compiler bug. The aforementioned
> reference to n1548 sec 6.7.9 para 10 is incorrect in that there _is_ an
> explicit initializer here. The relevant text in the standard is sec 6.7.9
> pp 16-21, which specifies that in the event that an explicit initializer
> does not completely cover (in a topological sense) the thing it is
> initializing, then the elements not covered shall be initialized as if they
> had _static_ storage duration; that is, they should be zeroed.
> 
> Now as I said, the Plan 9 C compilers aren't explicit C99 compliant. But
> given that the `c99` file describes things related to initializer lists as
> being unneeded because they were already implemented, one may assume it was
> believed that this was covered by c99 behavior. It isn't.
> 
> - Dan C.

So, no?

khm



Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct?

2019-04-01 Thread Dan Cross
On Mon, Apr 1, 2019 at 8:36 PM Kurt H Maier  wrote:

> On Mon, Apr 01, 2019 at 08:26:30PM -0400, Jeremy O'Brien wrote:
> > On Mon, Apr 1, 2019, at 11:33, Kyohei Kadota wrote:
> > > Hi, 9fans. I use 9legacy.
> > >
> > > About below program, I expected that flags field will initialize to
> > > zero but the value of flags was a garbage, ex, "f8f7".
> > > Is this expected?
> > >
> > > ```
> > > #include 
> > >
> > > struct option {
> > > int n;
> > > char *s;
> > > int flags;
> > > };
> > >
> > > int
> > > main(void)
> > > {
> > > struct option opt = {1, "test"};
> > > printf("%d %s %x\n", opt.n, opt.s, opt.flags);
> > > return 0;
> > > }
> > > ```
> > >
> > >
> >
> > According to C99: "If an object that has automatic storage duration is
> not initialized explicitly, its value is indeterminate."
> >
> > Stack variable == automatic storage duration. This appears to be correct
> behavior to me.
> >
>
> Can anyone provide the patches 9legacy uses to implement C99 compliance?


There were actually quite a few of them, mostly done by Geoff Collyer.  The
compiler sources list contains a list of desiderata in a file called `c99`;
of course, the plan9 compilers aren't completely compliant (they weren't
trying to be). Incidentally this file has been carried forward into, for
example, /sys/src/cmd/cc/c99 in the 9front distribution (and other plan9
derivatives).

In the present case, this appears to be a compiler bug. The aforementioned
reference to n1548 sec 6.7.9 para 10 is incorrect in that there _is_ an
explicit initializer here. The relevant text in the standard is sec 6.7.9
pp 16-21, which specifies that in the event that an explicit initializer
does not completely cover (in a topological sense) the thing it is
initializing, then the elements not covered shall be initialized as if they
had _static_ storage duration; that is, they should be zeroed.

Now as I said, the Plan 9 C compilers aren't explicit C99 compliant. But
given that the `c99` file describes things related to initializer lists as
being unneeded because they were already implemented, one may assume it was
believed that this was covered by c99 behavior. It isn't.

- Dan C.


Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-01 Thread Charles Forsyth
Yes, that's normal C behaviour. Only external and static storage is
guaranteed to be zero. In a modern environment it seems a little mean,
especially since you gave opt a partial initial value, but there are no
half-measures in C.

On Tue, 2 Apr 2019 at 01:27, Jeremy O'Brien  wrote:

> On Mon, Apr 1, 2019, at 11:33, Kyohei Kadota wrote:
> > Hi, 9fans. I use 9legacy.
> >
> > About below program, I expected that flags field will initialize to
> > zero but the value of flags was a garbage, ex, "f8f7".
> > Is this expected?
> >
> > ```
> > #include 
> >
> > struct option {
> > int n;
> > char *s;
> > int flags;
> > };
> >
> > int
> > main(void)
> > {
> > struct option opt = {1, "test"};
> > printf("%d %s %x\n", opt.n, opt.s, opt.flags);
> > return 0;
> > }
> > ```
> >
> >
>
> According to C99: "If an object that has automatic storage duration is not
> initialized explicitly, its value is indeterminate."
>
> Stack variable == automatic storage duration. This appears to be correct
> behavior to me.
>
>


Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct?

2019-04-01 Thread Kurt H Maier
On Mon, Apr 01, 2019 at 08:26:30PM -0400, Jeremy O'Brien wrote:
> On Mon, Apr 1, 2019, at 11:33, Kyohei Kadota wrote:
> > Hi, 9fans. I use 9legacy.
> > 
> > About below program, I expected that flags field will initialize to
> > zero but the value of flags was a garbage, ex, "f8f7".
> > Is this expected?
> > 
> > ```
> > #include 
> > 
> > struct option {
> > int n;
> > char *s;
> > int flags;
> > };
> > 
> > int
> > main(void)
> > {
> > struct option opt = {1, "test"};
> > printf("%d %s %x\n", opt.n, opt.s, opt.flags);
> > return 0;
> > }
> > ```
> > 
> >
> 
> According to C99: "If an object that has automatic storage duration is not 
> initialized explicitly, its value is indeterminate."
> 
> Stack variable == automatic storage duration. This appears to be correct 
> behavior to me.
> 

Can anyone provide the patches 9legacy uses to implement C99 compliance?


Thanks in advance,
khm



Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-01 Thread Jeremy O'Brien
On Mon, Apr 1, 2019, at 11:33, Kyohei Kadota wrote:
> Hi, 9fans. I use 9legacy.
> 
> About below program, I expected that flags field will initialize to
> zero but the value of flags was a garbage, ex, "f8f7".
> Is this expected?
> 
> ```
> #include 
> 
> struct option {
> int n;
> char *s;
> int flags;
> };
> 
> int
> main(void)
> {
> struct option opt = {1, "test"};
> printf("%d %s %x\n", opt.n, opt.s, opt.flags);
> return 0;
> }
> ```
> 
>

According to C99: "If an object that has automatic storage duration is not 
initialized explicitly, its value is indeterminate."

Stack variable == automatic storage duration. This appears to be correct 
behavior to me.



Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-01 Thread Skip Tavakkolian
It should initialize to zero. 8c and 5c both do the right thing here.

Which distribution and cputype?

On Mon, Apr 1, 2019, 8:34 AM Kyohei Kadota  wrote:

> Hi, 9fans. I use 9legacy.
>
> About below program, I expected that flags field will initialize to
> zero but the value of flags was a garbage, ex, "f8f7".
> Is this expected?
>
> ```
> #include 
>
> struct option {
> int n;
> char *s;
> int flags;
> };
>
> int
> main(void)
> {
> struct option opt = {1, "test"};
> printf("%d %s %x\n", opt.n, opt.s, opt.flags);
> return 0;
> }
> ```
>
>


Re: [9fans] Are there disadvantages to walk?

2019-04-01 Thread Brian L. Stuart
On Mon, 4/1/19, Ethan Gardener  wrote:
> I remember hearing of some disadvantage to
> walking directories, but can't remember what it was. 
> Could someone remind me, please?  Perhaps there was
> more than one, of course.  Perhaps a performance trick
> couldn't be employed?
 
The only complaint I've had about walk was the expectation
in the protocol that servers produce the list of Qids all
the way down.  That got in the way when experimenting
with a server that used a hash table of full path names
to speed the walk process.

BLS



Re: [9fans] Are there disadvantages to walk?

2019-04-01 Thread Ethan Gardener
On Mon, Apr 1, 2019, at 5:27 PM, hiro wrote:
> perhaps you mean that if you bind a lot you have to walk a lot :)

If that's the only issue, I'll be happy.  :)



Re: [9fans] Are there disadvantages to walk?

2019-04-01 Thread hiro
perhaps you mean that if you bind a lot you have to walk a lot :)



[9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-01 Thread Kyohei Kadota
Hi, 9fans. I use 9legacy.

About below program, I expected that flags field will initialize to
zero but the value of flags was a garbage, ex, "f8f7".
Is this expected?

```
#include 

struct option {
int n;
char *s;
int flags;
};

int
main(void)
{
struct option opt = {1, "test"};
printf("%d %s %x\n", opt.n, opt.s, opt.flags);
return 0;
}
```



[9fans] Are there disadvantages to walk?

2019-04-01 Thread Ethan Gardener
I remember hearing of some disadvantage to walking directories, but can't 
remember what it was.  Could someone remind me, please?  Perhaps there was more 
than one, of course.  Perhaps a performance trick couldn't be employed?